Program.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. namespace D3._1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) return;
  11. if (File.Exists(args[0]) == false) return;
  12. var file = File.OpenText(args[0]);
  13. var fabric = new int[1000, 1000];
  14. do
  15. {
  16. var line = file.ReadLine();
  17. if (line == null) break;
  18. var l = line.Split("@")[1];
  19. var xy = l.Split(":")[0];
  20. var wh = l.Split(":")[1];
  21. var x = int.Parse(xy.Split(",")[0]);
  22. var y = int.Parse(xy.Split(",")[1]);
  23. var w = int.Parse(wh.Split("x")[0]);
  24. var h = int.Parse(wh.Split("x")[1]);
  25. for (int i = x; i < x + w; i++)
  26. {
  27. for (int j = y; j < y + h; j++)
  28. {
  29. fabric[i, j]++;
  30. }
  31. }
  32. } while (true);
  33. int count = 0;
  34. for (int x = 0; x < 1000; x++)
  35. {
  36. for (int y = 0; y < 1000; y++)
  37. {
  38. if (fabric[x, y] >= 2) count++;
  39. }
  40. }
  41. Console.WriteLine(count);
  42. }
  43. }
  44. }