#include <bits/stdc++.h>
#define rep(i,a,b) for (auto i = (a); i <= (b); ++i)
#define per(i,a,b) for (auto i = (b); i >= (a); --i)
#define all(x) begin(x),end(x)
#define siz(x) int((x).size())
#define Mup(x,y) x = max(x,y)
#define mup(x,y) x = min(x,y)
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
using namespace std; using ll = long long; using ii = pair<int,int>;
const int N = 1e5+3;
int n, k;
char s[N];
set<ii> c, a;
bool make_square(int x, int y) {
rep(i,0,1) rep(j,0,1)
if (not c.count({x+i,y+j})) return false;
return true;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k >> &s[1];
int x = 0, y = 0;
c.insert({0,0});
rep(i,1,n) {
if (s[i] == 'E') {
c.insert({x,++y});
} else if (s[i] == 'W') {
c.insert({x,--y});
} else if (s[i] == 'N') {
c.insert({++x,y});
} else if (s[i] == 'S') {
c.insert({--x,y});
} else assert(0);
rep(i,-1,1) rep(j,-1,1) {
if (make_square(x+i,y+j)) a.insert({x+i,y+j});
}
}
printf("%d", siz(a));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
5 ms |
340 KB |
Output is correct |
28 |
Correct |
16 ms |
596 KB |
Output is correct |
29 |
Correct |
54 ms |
1496 KB |
Output is correct |
30 |
Correct |
83 ms |
1636 KB |
Output is correct |
31 |
Correct |
86 ms |
4516 KB |
Output is correct |
32 |
Correct |
125 ms |
2152 KB |
Output is correct |
33 |
Correct |
120 ms |
2456 KB |
Output is correct |
34 |
Correct |
125 ms |
2516 KB |
Output is correct |
35 |
Correct |
119 ms |
2360 KB |
Output is correct |
36 |
Correct |
119 ms |
2208 KB |
Output is correct |
37 |
Correct |
117 ms |
2376 KB |
Output is correct |
38 |
Correct |
123 ms |
2296 KB |
Output is correct |
39 |
Correct |
115 ms |
2428 KB |
Output is correct |
40 |
Correct |
127 ms |
2092 KB |
Output is correct |
41 |
Correct |
115 ms |
2132 KB |
Output is correct |
42 |
Correct |
119 ms |
1760 KB |
Output is correct |
43 |
Correct |
114 ms |
2560 KB |
Output is correct |
44 |
Correct |
119 ms |
2252 KB |
Output is correct |
45 |
Correct |
114 ms |
1928 KB |
Output is correct |
46 |
Correct |
73 ms |
2764 KB |
Output is correct |
47 |
Correct |
85 ms |
2752 KB |
Output is correct |
48 |
Correct |
81 ms |
5104 KB |
Output is correct |
49 |
Correct |
96 ms |
5192 KB |
Output is correct |
50 |
Correct |
82 ms |
5192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
5 ms |
340 KB |
Output is correct |
28 |
Correct |
16 ms |
596 KB |
Output is correct |
29 |
Correct |
54 ms |
1496 KB |
Output is correct |
30 |
Correct |
83 ms |
1636 KB |
Output is correct |
31 |
Correct |
86 ms |
4516 KB |
Output is correct |
32 |
Correct |
125 ms |
2152 KB |
Output is correct |
33 |
Correct |
120 ms |
2456 KB |
Output is correct |
34 |
Correct |
125 ms |
2516 KB |
Output is correct |
35 |
Correct |
119 ms |
2360 KB |
Output is correct |
36 |
Correct |
119 ms |
2208 KB |
Output is correct |
37 |
Correct |
117 ms |
2376 KB |
Output is correct |
38 |
Correct |
123 ms |
2296 KB |
Output is correct |
39 |
Correct |
115 ms |
2428 KB |
Output is correct |
40 |
Correct |
127 ms |
2092 KB |
Output is correct |
41 |
Correct |
115 ms |
2132 KB |
Output is correct |
42 |
Correct |
119 ms |
1760 KB |
Output is correct |
43 |
Correct |
114 ms |
2560 KB |
Output is correct |
44 |
Correct |
119 ms |
2252 KB |
Output is correct |
45 |
Correct |
114 ms |
1928 KB |
Output is correct |
46 |
Correct |
73 ms |
2764 KB |
Output is correct |
47 |
Correct |
85 ms |
2752 KB |
Output is correct |
48 |
Correct |
81 ms |
5104 KB |
Output is correct |
49 |
Correct |
96 ms |
5192 KB |
Output is correct |
50 |
Correct |
82 ms |
5192 KB |
Output is correct |
51 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |