Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Linq;
  5. using System.Numerics;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace DebbugingSpace
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. BigInteger count = BigInteger.Parse(Console.ReadLine());
  16.  
  17. Dictionary<string, Dictionary<string, string>> files =
  18. new Dictionary<string, Dictionary<string, string>>();
  19.  
  20. string fileName = "";
  21.  
  22. for (int i = 0; i < count; i++)
  23. {
  24.  
  25. var input = Console.ReadLine();
  26. var inputActual = input.Split(new char[] {'\\', ';', ' '}, StringSplitOptions.RemoveEmptyEntries)
  27. .ToArray();
  28.  
  29. string homeDirectory = inputActual[0];
  30.  
  31. string size = inputActual.Last();
  32.  
  33. string pattern = @"\b\w+.\w+\b";
  34.  
  35. foreach (Match m in Regex.Matches(input, pattern))
  36. {
  37.  
  38. fileName = m.Value;
  39.  
  40. }
  41.  
  42. if (!files.ContainsKey(homeDirectory))
  43. {
  44.  
  45. files.Add(homeDirectory,new Dictionary<string, string>());
  46.  
  47. }
  48.  
  49. else
  50. {
  51. if (!files[homeDirectory].ContainsKey(fileName))
  52. {
  53.  
  54. files[homeDirectory].Add(fileName, size);
  55. }
  56.  
  57. else
  58. {
  59. files[homeDirectory][fileName] = size;
  60. }
  61. }
  62.  
  63. }
  64.  
  65. var lastInput = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries)
  66. .ToArray();
  67.  
  68. string fileExtension = lastInput.First();
  69. string rootResult = lastInput.Last();
  70.  
  71. foreach (var item in files)
  72. {
  73.  
  74. if (item.Equals(rootResult) && item.Value.ContainsKey(fileExtension))
  75. {
  76.  
  77. Console.WriteLine("Yes");
  78.  
  79. }
  80.  
  81. else
  82. {
  83. Console.WriteLine("No");
  84. break;
  85. }
  86.  
  87. }
  88.  
  89. }
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement