Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem_4.Roli___The_Coder
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var dic = new Dictionary<string, Dictionary<string, List<string>>>();
  14. while (true)
  15. {
  16. string input = Console.ReadLine();
  17.  
  18. if (input == "Time for Code") break;
  19.  
  20. var tokens = input.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  21.  
  22. var id = tokens[0];
  23. var eventName = tokens[1];
  24. if (!eventName.Contains('#')) continue;
  25. var names = new List<string>();
  26. for (int i = 2; i < tokens.Length; i++)
  27. {
  28. var participant = tokens[i];
  29. names.Add(participant);
  30. }
  31. names = names.Distinct().ToList();
  32. if (dic.ContainsKey(id))
  33. {
  34. if (!dic[id].ContainsKey(eventName)) continue;
  35. else if (dic[id].ContainsKey(eventName))
  36. {
  37. dic[id][eventName].AddRange(names);
  38. dic[id][eventName] = dic[id][eventName].Distinct().ToList();
  39. }
  40. }
  41. else if (!dic.ContainsKey(id))
  42. {
  43. dic[id] = new Dictionary<string, List<string>>();
  44. if (!dic[id].ContainsKey(eventName))
  45. {
  46. dic[id][eventName] = names;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement