Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <stdio.h>
- #include <math.h>
- #include <algorithm>
- using namespace std;
- int pol[15001][15001];
- int main()
- {
- int n, m;
- cin >> n >> m;
- int gor = 0;
- int ver = 0;
- for(int i = 0; i < n; i++)
- {
- int x, y;
- x--;
- y--;
- char a;
- cin >> x >> y >> a;
- if(pol[x][y] != 1 && pol[x][y] != 2 && pol[x][y] != 3)
- {
- if(a == 'N' || a == 'S')
- {
- ver++;
- for(int j = 0; j < m; j++)
- {
- pol[x][j] = 1;
- }
- }
- if(a == 'W' || a == 'E')
- {
- gor++;
- for(int j = 0; j < m; j++)
- {
- pol[j][y] = 2;
- }
- }
- }
- else
- {
- if((a == 'N' || a == 'S') && (pol[x][y] != 1 || pol[x][y] != 3))
- {
- ver++;
- for(int j = 0; j < m; j++)
- {
- pol[x][j] = 3;
- }
- }
- if((a == 'E' || a == 'W') && (pol[x][y] != 2 && pol[x][y] != 3))
- {
- gor++;
- for(int j = 0; j < m; j++)
- {
- pol[j][y] = 3;
- }
- }
- }
- }
- cout << m*m*6 + gor*ver*2 - gor * 4 * m - ver * m * 4;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement