# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128499 | 2019-07-11T04:08:04 Z | 이온조(#3159) | None (JOI16_ho_t4) | C++14 | 1000 ms | 209244 KB |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; #define X first #define Y second pii df; int N, K; char S[100009]; void mv(pii &CR, char c) { if(c == 'S') --CR.Y; if(c == 'N') ++CR.Y; if(c == 'W') --CR.X; if(c == 'E') ++CR.X; } void input() { scanf("%d%d",&N,&K); for(int i=1; i<=N; i++) { scanf(" %c", &S[i]); mv(df, S[i]); } if(df.X < 0) { df.X = -df.X; for(int i=1; i<=N; i++) { if(S[i] == 'W') S[i] = 'E'; else if(S[i] == 'E') S[i] = 'W'; } } if(df.Y < 0) { df.Y = -df.Y; for(int i=1; i<=N; i++) { if(S[i] == 'N') S[i] = 'S'; else if(S[i] == 'S') S[i] = 'N'; } } } set<pii> st; void go(pii &now) { st.insert(now); for(int i=1; i<=N; i++) { mv(now, S[i]); st.insert(now); } } int cnt() { int ret = 0; for(auto& it: st) { int c = 0; if(st.find({it.X+1, it.Y}) != st.end()) ++c; if(st.find({it.X, it.Y+1}) != st.end()) ++c; if(st.find({it.X+1, it.Y+1}) != st.end()) ++c; if(c == 3) ++ret; } return ret; } int main() { input(); pii now = {0, 0}; for(int i=0; i<K; i++) go(now); printf("%d", cnt()); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 256 KB | Output is correct |
27 | Correct | 3 ms | 380 KB | Output is correct |
28 | Correct | 6 ms | 504 KB | Output is correct |
29 | Correct | 15 ms | 1144 KB | Output is correct |
30 | Correct | 19 ms | 1144 KB | Output is correct |
31 | Correct | 51 ms | 4444 KB | Output is correct |
32 | Correct | 26 ms | 1528 KB | Output is correct |
33 | Correct | 29 ms | 1656 KB | Output is correct |
34 | Correct | 28 ms | 1784 KB | Output is correct |
35 | Correct | 28 ms | 1656 KB | Output is correct |
36 | Correct | 25 ms | 1528 KB | Output is correct |
37 | Correct | 27 ms | 1656 KB | Output is correct |
38 | Correct | 28 ms | 1656 KB | Output is correct |
39 | Correct | 27 ms | 1656 KB | Output is correct |
40 | Correct | 26 ms | 1528 KB | Output is correct |
41 | Correct | 25 ms | 1404 KB | Output is correct |
42 | Correct | 23 ms | 1272 KB | Output is correct |
43 | Correct | 28 ms | 1784 KB | Output is correct |
44 | Correct | 26 ms | 1528 KB | Output is correct |
45 | Correct | 25 ms | 1400 KB | Output is correct |
46 | Correct | 45 ms | 2936 KB | Output is correct |
47 | Correct | 43 ms | 2936 KB | Output is correct |
48 | Correct | 63 ms | 5244 KB | Output is correct |
49 | Correct | 88 ms | 5240 KB | Output is correct |
50 | Correct | 99 ms | 5212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 137 ms | 11300 KB | Output is correct |
27 | Correct | 682 ms | 128 KB | Output is correct |
28 | Execution timed out | 1081 ms | 209244 KB | Time limit exceeded |
29 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 256 KB | Output is correct |
27 | Correct | 3 ms | 380 KB | Output is correct |
28 | Correct | 6 ms | 504 KB | Output is correct |
29 | Correct | 15 ms | 1144 KB | Output is correct |
30 | Correct | 19 ms | 1144 KB | Output is correct |
31 | Correct | 51 ms | 4444 KB | Output is correct |
32 | Correct | 26 ms | 1528 KB | Output is correct |
33 | Correct | 29 ms | 1656 KB | Output is correct |
34 | Correct | 28 ms | 1784 KB | Output is correct |
35 | Correct | 28 ms | 1656 KB | Output is correct |
36 | Correct | 25 ms | 1528 KB | Output is correct |
37 | Correct | 27 ms | 1656 KB | Output is correct |
38 | Correct | 28 ms | 1656 KB | Output is correct |
39 | Correct | 27 ms | 1656 KB | Output is correct |
40 | Correct | 26 ms | 1528 KB | Output is correct |
41 | Correct | 25 ms | 1404 KB | Output is correct |
42 | Correct | 23 ms | 1272 KB | Output is correct |
43 | Correct | 28 ms | 1784 KB | Output is correct |
44 | Correct | 26 ms | 1528 KB | Output is correct |
45 | Correct | 25 ms | 1400 KB | Output is correct |
46 | Correct | 45 ms | 2936 KB | Output is correct |
47 | Correct | 43 ms | 2936 KB | Output is correct |
48 | Correct | 63 ms | 5244 KB | Output is correct |
49 | Correct | 88 ms | 5240 KB | Output is correct |
50 | Correct | 99 ms | 5212 KB | Output is correct |
51 | Correct | 137 ms | 11300 KB | Output is correct |
52 | Correct | 682 ms | 128 KB | Output is correct |
53 | Execution timed out | 1081 ms | 209244 KB | Time limit exceeded |
54 | Halted | 0 ms | 0 KB | - |