#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define ll long long
set<pii> s;
int dx[512], dy[512];
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, k; cin >> n >> k;
string A; cin >> A;
dx['S']--, dx['N']++, dy['E']++, dy['W']--;
int x = 0, y = 0;
s.insert({x,y});
for(;k--;){
for(char i : A) {
x += dx[i], y += dy[i];
s.insert({x,y});
}
}
ll c = 0;
for(auto i : s) if(
s.find({i.first+1,i.second}) != s.end() &&
s.find({i.first,i.second+1}) != s.end() &&
s.find({i.first+1,i.second+1}) != s.end()
) c++;
cout << c;
}
Compilation message
2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:16:21: warning: array subscript has type 'char' [-Wchar-subscripts]
16 | x += dx[i], y += dy[i];
| ^
2016_ho_t4.cpp:16:33: warning: array subscript has type 'char' [-Wchar-subscripts]
16 | x += dx[i], y += dy[i];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 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 |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
328 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
7 ms |
996 KB |
Output is correct |
30 |
Correct |
10 ms |
1164 KB |
Output is correct |
31 |
Correct |
20 ms |
4488 KB |
Output is correct |
32 |
Correct |
12 ms |
1440 KB |
Output is correct |
33 |
Correct |
12 ms |
1572 KB |
Output is correct |
34 |
Correct |
12 ms |
1748 KB |
Output is correct |
35 |
Correct |
13 ms |
1620 KB |
Output is correct |
36 |
Correct |
11 ms |
1492 KB |
Output is correct |
37 |
Correct |
14 ms |
1592 KB |
Output is correct |
38 |
Correct |
12 ms |
1616 KB |
Output is correct |
39 |
Correct |
12 ms |
1664 KB |
Output is correct |
40 |
Correct |
12 ms |
1492 KB |
Output is correct |
41 |
Correct |
12 ms |
1348 KB |
Output is correct |
42 |
Correct |
10 ms |
1236 KB |
Output is correct |
43 |
Correct |
12 ms |
1748 KB |
Output is correct |
44 |
Correct |
13 ms |
1492 KB |
Output is correct |
45 |
Correct |
11 ms |
1268 KB |
Output is correct |
46 |
Correct |
15 ms |
2772 KB |
Output is correct |
47 |
Correct |
14 ms |
2828 KB |
Output is correct |
48 |
Correct |
18 ms |
5204 KB |
Output is correct |
49 |
Correct |
29 ms |
5204 KB |
Output is correct |
50 |
Correct |
29 ms |
5196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
70 ms |
11312 KB |
Output is correct |
27 |
Correct |
471 ms |
304 KB |
Output is correct |
28 |
Runtime error |
701 ms |
262144 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
328 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
7 ms |
996 KB |
Output is correct |
30 |
Correct |
10 ms |
1164 KB |
Output is correct |
31 |
Correct |
20 ms |
4488 KB |
Output is correct |
32 |
Correct |
12 ms |
1440 KB |
Output is correct |
33 |
Correct |
12 ms |
1572 KB |
Output is correct |
34 |
Correct |
12 ms |
1748 KB |
Output is correct |
35 |
Correct |
13 ms |
1620 KB |
Output is correct |
36 |
Correct |
11 ms |
1492 KB |
Output is correct |
37 |
Correct |
14 ms |
1592 KB |
Output is correct |
38 |
Correct |
12 ms |
1616 KB |
Output is correct |
39 |
Correct |
12 ms |
1664 KB |
Output is correct |
40 |
Correct |
12 ms |
1492 KB |
Output is correct |
41 |
Correct |
12 ms |
1348 KB |
Output is correct |
42 |
Correct |
10 ms |
1236 KB |
Output is correct |
43 |
Correct |
12 ms |
1748 KB |
Output is correct |
44 |
Correct |
13 ms |
1492 KB |
Output is correct |
45 |
Correct |
11 ms |
1268 KB |
Output is correct |
46 |
Correct |
15 ms |
2772 KB |
Output is correct |
47 |
Correct |
14 ms |
2828 KB |
Output is correct |
48 |
Correct |
18 ms |
5204 KB |
Output is correct |
49 |
Correct |
29 ms |
5204 KB |
Output is correct |
50 |
Correct |
29 ms |
5196 KB |
Output is correct |
51 |
Correct |
70 ms |
11312 KB |
Output is correct |
52 |
Correct |
471 ms |
304 KB |
Output is correct |
53 |
Runtime error |
701 ms |
262144 KB |
Execution killed with signal 9 |
54 |
Halted |
0 ms |
0 KB |
- |