Advertisement
Guest User

Untitled

a guest
May 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int pol[15001][15001];
  10.  
  11. int main()
  12. {
  13. int n, m;
  14. cin >> n >> m;
  15. int gor = 0;
  16. int ver = 0;
  17. for(int i = 0; i < n; i++)
  18. {
  19. int x, y;
  20. x--;
  21. y--;
  22. char a;
  23. cin >> x >> y >> a;
  24. if(pol[x][y] != 1 && pol[x][y] != 2 && pol[x][y] != 3)
  25. {
  26. if(a == 'N' || a == 'S')
  27. {
  28. ver++;
  29. for(int j = 0; j < m; j++)
  30. {
  31. pol[x][j] = 1;
  32. }
  33. }
  34. if(a == 'W' || a == 'E')
  35. {
  36. gor++;
  37. for(int j = 0; j < m; j++)
  38. {
  39. pol[j][y] = 2;
  40. }
  41. }
  42. }
  43. else
  44. {
  45. if((a == 'N' || a == 'S') && (pol[x][y] != 1 || pol[x][y] != 3))
  46. {
  47. ver++;
  48. for(int j = 0; j < m; j++)
  49. {
  50. pol[x][j] = 3;
  51. }
  52. }
  53. if((a == 'E' || a == 'W') && (pol[x][y] != 2 && pol[x][y] != 3))
  54. {
  55. gor++;
  56. for(int j = 0; j < m; j++)
  57. {
  58. pol[j][y] = 3;
  59. }
  60. }
  61. }
  62. }
  63. cout << m*m*6 + gor*ver*2 - gor * 4 * m - ver * m * 4;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement