alexbancheva

MOBA Challenger

Aug 31st, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5.  
  6. namespace MOBAChallenger_Krassy
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string comand = "";
  13.  
  14.             Dictionary<string, Dictionary<string, int>> pool = new Dictionary<string, Dictionary<string, int>>();
  15.  
  16.            // bool isHaveSamePosition = false;
  17.  
  18.             while ((comand = Console.ReadLine()) != "Seаson end")
  19.             {
  20.                 if (comand.Contains("->"))
  21.                 {
  22.                     string[] comandInArr = comand.Split(" -> ", StringSplitOptions.RemoveEmptyEntries).ToArray();
  23.                     string player = comandInArr[0];
  24.                     string position = comandInArr[1];
  25.                     int skill = int.Parse(comandInArr[2]);
  26.  
  27.                     if (!pool.ContainsKey(player))
  28.                     {
  29.                         pool.Add(player, new Dictionary<string, int>());
  30.                         pool[player].Add(position, skill);
  31.                     }
  32.                     else if (!pool[player].ContainsKey(position))
  33.                     {
  34.                         pool[player].Add(position, skill);
  35.                     }
  36.                     else if (pool[player].ContainsKey(position))
  37.                     {
  38.                        // pool[player][position] += skill;
  39.                         int MaxVelue = int.MinValue;
  40.                         if (MaxVelue <= skill)
  41.                         {
  42.                             MaxVelue = skill;
  43.                             pool[player][position] = MaxVelue;
  44.                         }
  45.                     }
  46.  
  47.                 }
  48.                 else if (comand.Contains("vs"))
  49.                 {
  50.                     string[] comandInArr = comand.Split(" vs ", StringSplitOptions.RemoveEmptyEntries).ToArray();
  51.                     string playerOne = comandInArr[0];
  52.                     string playerTwo = comandInArr[1];
  53.  
  54.                     //if (!pool.ContainsKey(playerOne) || !pool.ContainsKey(playerTwo))
  55.                     //{
  56.                     //    continue;
  57.                     //}
  58.                     //bool serchLestOneCommon = false;
  59.  
  60.                     //foreach (var item in pool[playerOne])
  61.                     //{
  62.                     //    if (pool[playerTwo].ContainsKey(item.Key))
  63.                     //    {
  64.                     //        serchLestOneCommon = true;
  65.                     //    }
  66.                     //}
  67.                     if (pool.ContainsKey(playerOne) && pool.ContainsKey(playerTwo))
  68.                     {
  69.                         foreach (var info in pool[playerOne])
  70.                         {
  71.                             foreach (var inf in pool[playerTwo])
  72.                             {
  73.                                 if (info.Key == inf.Key)
  74.                                 {
  75.                                     if (pool[playerOne].Values.Sum() > pool[playerTwo].Values.Sum())
  76.                                     {
  77.                                         pool.Remove(playerTwo);
  78.                                     }
  79.                                     else if (pool[playerOne].Values.Sum() < pool[playerTwo].Values.Sum())
  80.                                     {
  81.                                         pool.Remove(playerOne);
  82.                                     }
  83.                                 }
  84.                             }
  85.                         }
  86.                     }
  87.                 }
  88.                 else if (comand.Contains("end"))
  89.                 {
  90.                     break;
  91.                 }
  92.             }
  93.  
  94.             //if (comand == "Season end")
  95.             //{
  96.                 foreach (var info in pool.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x.Key))
  97.                 {
  98.                     Console.WriteLine($"{info.Key}: {info.Value.Values.Sum()} skill");
  99.  
  100.                     foreach (var pair in info.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  101.                     {
  102.                         Console.WriteLine($"- {pair.Key} <::> {pair.Value}");
  103.                     }
  104.                 }
  105.            // }
  106.            
  107.         }
  108.     }
  109. }
  110.  
Advertisement
Add Comment
Please, Sign In to add comment