Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _3.RoliTheCoder
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dict = new Dictionary<string, Dictionary<string, List<string>>>();
- while (true)
- {
- string[] input = Console.ReadLine().Split().ToArray();
- bool isValid = true;
- if ((input[0] == "Time") && (input[1] == "for") && (input[2] == "Code"))
- {
- break;
- }
- if ((input.Length>=2)&&(!input[1].StartsWith("#")))
- {
- isValid = false;
- }
- for (int i = 2; i < input.Length; i++)
- {
- if (!input[i].StartsWith("@"))
- {
- isValid = false;
- break;
- }
- }
- if (isValid == false)
- {
- continue;
- }
- string id = input[0];
- string eventName = "";
- if (input.Length >= 2)
- {
- eventName += input[1].TrimStart('#');
- }
- var inner = new List<string>();
- for (int i = 2; i < input.Length; i++)
- {
- inner.Add(input[i]);
- }
- var innerList = inner.Distinct().ToList();
- if ((!dict.ContainsKey(id))&&(eventName !=""))
- {
- var innerDict = new Dictionary<string, List<string>>();
- innerDict.Add(eventName, innerList);
- dict.Add(id, innerDict);
- }
- else
- {
- if (dict[id].ContainsKey(eventName))
- {
- for (int i = 0; i < innerList.Count; i++)
- {
- if (!dict[id][eventName].Contains(innerList[i]))
- {
- dict[id][eventName].Add(innerList[i]);
- }
- }
- }
- }
- }
- if (dict.Count > 0)
- {
- foreach (var i in dict.OrderByDescending(x => dict[x.Key].Values.First().Count))
- {
- foreach (var eventt in i.Value)
- {
- Console.WriteLine($"{eventt.Key} - {eventt.Value.Count}");
- foreach (var item in eventt.Value.OrderBy(x => x))
- {
- Console.WriteLine($"{item}");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement