Advertisement
Guest User

Roli - The Coder

a guest
Feb 28th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace RoliTheCoder
  6. {
  7.     class RoliTheCoder
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string[] input = Console.ReadLine().Split().ToArray();
  12.  
  13.             Dictionary<int, Dictionary<string, List<string>>> output = new Dictionary<int, Dictionary<string, List<string>>>();
  14.  
  15.             while (input[0] != "Time")
  16.             {
  17.                 int id=int.Parse(input[0]);
  18.                 string events=input[1];
  19.  
  20.                 if (!events.StartsWith("#"))
  21.                 {
  22.                     input = Console.ReadLine().Split().ToArray();
  23.                     continue;
  24.                 }
  25.  
  26.                 if (output.ContainsKey(id) == false)
  27.                 {
  28.                     var helpDic = new Dictionary<string, List<string>>();
  29.                     var helList = new List<string>();
  30.                     for (int i = 2; i < input.Length; i++)
  31.                     {
  32.                         helList.Add(input[i]);
  33.                     }
  34.                     helpDic.Add(events, helList);
  35.  
  36.                     output.Add(id, helpDic);
  37.                 }
  38.                 else
  39.                 {
  40.                     if (output[id].ContainsKey(events)==false)
  41.                     {
  42.                         input = Console.ReadLine().Split().ToArray();
  43.                         continue;
  44.                     }
  45.                     else
  46.                     {
  47.                         List<string> helpList = new List<string>();
  48.                         for (int i =2 ; i < input.Length; i++)
  49.                         {
  50.                             helpList.Add(input[i]);
  51.                         }
  52.                         output[id][events].AddRange(helpList);
  53.                         output[id][events]= output[id][events].Distinct().OrderBy(n=>n).ToList();
  54.                     }
  55.                 }
  56.                 input = Console.ReadLine().Split().ToArray();
  57.             }
  58.             foreach (var item in output.OrderByDescending(x=>x.Value.Values.Count()))
  59.             {
  60.                 int id = item.Key;
  61.                 var allevents = item.Value.OrderByDescending(x=>x.Value.Count);
  62.  
  63.                 foreach (var ev in allevents)
  64.                 {
  65.                     Console.WriteLine($"{ev.Key.Trim('#')} - {ev.Value.Count}");
  66.                     foreach (var names in ev.Value.OrderBy(n=>n))
  67.                     {
  68.                         Console.WriteLine(names);
  69.                     }
  70.                 }
  71.             }
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement