Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace DragonArmy
- {
- class DragonArmy
- {
- static void Main()
- {
- int numberOfLines = int.Parse(Console.ReadLine());
- Dictionary<string, List<Dictionary<string, List<Dictionary<string, int>>>>> dragons = new Dictionary<string, List<Dictionary<string, List<Dictionary<string, int>>>>>();
- for (int i = 0; i < numberOfLines; i++)
- {
- string[] input = Console.ReadLine().Split(' ');
- SetDefaultValues(input);
- List<Dictionary<string, int>> dragonStats = new List<Dictionary<string, int>>();
- Dictionary<string, List<Dictionary<string, int>>> dragon = new Dictionary<string, List<Dictionary<string, int>>>();
- string dragonColor = input[0];
- string dragonName = input[1];
- int dragonDamage = int.Parse(input[2]);
- int dragonHealth = int.Parse(input[3]);
- int dragonArmor = int.Parse(input[4]);
- dragonStats.Add(new Dictionary<string, int> { { "damage", dragonDamage } });
- dragonStats.Add(new Dictionary<string, int> { { "health", dragonHealth } });
- dragonStats.Add(new Dictionary<string, int> { { "armor", dragonArmor } });
- dragon.Add(dragonName, dragonStats);
- if (!dragons.ContainsKey(dragonColor))
- {
- dragons.Add(dragonColor, new List<Dictionary<string, List<Dictionary<string, int>>>> { dragon});
- }
- else
- {
- if(!dragons.ContainsValue(new List<Dictionary<string, List<Dictionary<string, int>>>> { dragon }))
- {
- dragons[dragonColor].Add(dragon);
- }
- }
- }
- //Стигам до тук
- foreach (var dragon in dragons)
- {
- string name = dragon.Key;
- Console.WriteLine("{0}::({1:0.00}/{2:0.00}/{3:0.00})",name,dragon.Value.Average(x=>x.Values.));
- }
- }
- private static string[] SetDefaultValues(string[] input)
- {
- for (int i = 0; i < input.Length; i++)
- {
- if(input[i] == "null")
- {
- if(i == 2)
- {
- input[i] = "250";
- }
- else if(i == 3)
- {
- input[i] = "45";
- }
- else if(i == 4)
- {
- input[i] = "10";
- }
- }
- }
- return input;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement