Advertisement
Iv555

Untitled

Feb 18th, 2022
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4.  
  5. namespace T06Wardrobe
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. int n = int.Parse(Console.ReadLine());
  13.  
  14. Dictionary<string, Dictionary<string, int>> allColors_Clothes_Count =
  15. new Dictionary<string, Dictionary<string, int>>();
  16.  
  17. for (int i = 0; i < n; i++)
  18. {
  19. string[] input = Console.ReadLine().Split(new[] { " -> ", "," }, StringSplitOptions.RemoveEmptyEntries);
  20. string currColor = input[0];
  21.  
  22. if (allColors_Clothes_Count.ContainsKey(currColor) == false)
  23. {
  24. allColors_Clothes_Count.Add(currColor, new Dictionary<string, int>());
  25. }
  26.  
  27. for (int j = 1; j < input.Length; j++)
  28. {
  29. string currClothing = input[j];
  30. if (!allColors_Clothes_Count[currColor].ContainsKey(currClothing))
  31. {
  32. allColors_Clothes_Count[currColor].Add(currClothing, 0);
  33.  
  34. }
  35.  
  36. allColors_Clothes_Count[currColor][currClothing]++;
  37. }
  38. }
  39.  
  40. string[] itemToFind = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
  41. string colorToFind = itemToFind[0];
  42. string clothingToFind = itemToFind[1];
  43.  
  44. foreach (KeyValuePair<string, Dictionary<string, int>> color in allColors_Clothes_Count)
  45. {
  46. Console.WriteLine($"{color.Key} clothes:");
  47. foreach (KeyValuePair<string, int> clothing in color.Value)
  48. {
  49. if (color.Key == colorToFind && clothing.Key == clothingToFind)
  50. {
  51. Console.WriteLine($"* {clothing.Key} - {clothing.Value} (found!)");
  52. }
  53. else
  54. {
  55. Console.WriteLine($"* {clothing.Key} - {clothing.Value}");
  56. }
  57.  
  58. }
  59. }
  60.  
  61. }
  62. }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement