#include <bits/stdc++.h>
using namespace std;
#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const ll LINF = ll(4e18) + ll(2e15);
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
static int LamyIsCute = []() {
EmiliaMyWife
return 48763;
}();
signed main() {
int n, k;
cin >> n >> k;
assert(k == 1);
string s;
cin >> s;
set<pair<int, int>> owo;
owo.insert({0, 0});
for(int i = 0, x = 0, y = 0; i < n; i++) {
if(s[i] == 'E')
x++;
if(s[i] == 'W')
x--;
if(s[i] == 'N')
y++;
if(s[i] == 'S')
y--;
owo.insert({x, y});
}
int res = 0;
for(const auto &[x, y] : owo)
res += owo.count({x + 1, y}) && owo.count({x, y + 1}) && owo.count({x + 1, y + 1});
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
0 ms |
208 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
452 KB |
Output is correct |
29 |
Correct |
8 ms |
960 KB |
Output is correct |
30 |
Correct |
13 ms |
1104 KB |
Output is correct |
31 |
Correct |
29 ms |
4460 KB |
Output is correct |
32 |
Correct |
17 ms |
1352 KB |
Output is correct |
33 |
Correct |
16 ms |
1616 KB |
Output is correct |
34 |
Correct |
16 ms |
1784 KB |
Output is correct |
35 |
Correct |
17 ms |
1540 KB |
Output is correct |
36 |
Correct |
14 ms |
1500 KB |
Output is correct |
37 |
Correct |
15 ms |
1488 KB |
Output is correct |
38 |
Correct |
15 ms |
1576 KB |
Output is correct |
39 |
Correct |
15 ms |
1576 KB |
Output is correct |
40 |
Correct |
14 ms |
1488 KB |
Output is correct |
41 |
Correct |
14 ms |
1320 KB |
Output is correct |
42 |
Correct |
13 ms |
1192 KB |
Output is correct |
43 |
Correct |
17 ms |
1728 KB |
Output is correct |
44 |
Correct |
16 ms |
1444 KB |
Output is correct |
45 |
Correct |
12 ms |
1264 KB |
Output is correct |
46 |
Correct |
19 ms |
2852 KB |
Output is correct |
47 |
Correct |
21 ms |
2748 KB |
Output is correct |
48 |
Correct |
29 ms |
5192 KB |
Output is correct |
49 |
Correct |
24 ms |
5144 KB |
Output is correct |
50 |
Correct |
31 ms |
5164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
0 ms |
208 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
452 KB |
Output is correct |
29 |
Correct |
8 ms |
960 KB |
Output is correct |
30 |
Correct |
13 ms |
1104 KB |
Output is correct |
31 |
Correct |
29 ms |
4460 KB |
Output is correct |
32 |
Correct |
17 ms |
1352 KB |
Output is correct |
33 |
Correct |
16 ms |
1616 KB |
Output is correct |
34 |
Correct |
16 ms |
1784 KB |
Output is correct |
35 |
Correct |
17 ms |
1540 KB |
Output is correct |
36 |
Correct |
14 ms |
1500 KB |
Output is correct |
37 |
Correct |
15 ms |
1488 KB |
Output is correct |
38 |
Correct |
15 ms |
1576 KB |
Output is correct |
39 |
Correct |
15 ms |
1576 KB |
Output is correct |
40 |
Correct |
14 ms |
1488 KB |
Output is correct |
41 |
Correct |
14 ms |
1320 KB |
Output is correct |
42 |
Correct |
13 ms |
1192 KB |
Output is correct |
43 |
Correct |
17 ms |
1728 KB |
Output is correct |
44 |
Correct |
16 ms |
1444 KB |
Output is correct |
45 |
Correct |
12 ms |
1264 KB |
Output is correct |
46 |
Correct |
19 ms |
2852 KB |
Output is correct |
47 |
Correct |
21 ms |
2748 KB |
Output is correct |
48 |
Correct |
29 ms |
5192 KB |
Output is correct |
49 |
Correct |
24 ms |
5144 KB |
Output is correct |
50 |
Correct |
31 ms |
5164 KB |
Output is correct |
51 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
52 |
Halted |
0 ms |
0 KB |
- |