# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594102 | 2022-07-12T05:45:02 Z | 조영욱(#8434) | None (JOI16_ho_t4) | C++17 | 1000 ms | 38312 KB |
#include <bits/stdc++.h> using namespace std; int n,k; char str[100001]; typedef pair<int,int> P; int main() { scanf("%d %d",&n,&k); scanf("%s",str); if (k<=5*n) { int ret=0; set<P> s; s.insert(P(0,0)); int x=0; int y=0; for(int j=0;j<k;j++) { for(int i=0;i<n;i++) { if (str[i]=='E') { x++; } if (str[i]=='W') { x--; } if (str[i]=='N') { y++; } if (str[i]=='S') { y--; } s.insert(P(x,y)); } } for(auto now:s) { bool flag=true; for(int i=1;i<4;i++) { if (s.find(P(now.first+i/2,now.second+i%2))==s.end()) { flag=false; break; } } if (flag) { ret++; } } printf("%d",ret); return 0; } long long ret=0; set<P> s; s.insert(P(0,0)); int x=0; int y=0; for(int j=0;j<5*n;j++) { for(int i=0;i<n;i++) { if (str[i]=='E') { x++; } if (str[i]=='W') { x--; } if (str[i]=='N') { y++; } if (str[i]=='S') { y--; } s.insert(P(x,y)); } } for(auto now:s) { bool flag=true; for(int i=1;i<4;i++) { if (s.find(P(now.first+i/2,now.second+i%2))==s.end()) { flag=false; break; } } if (flag) { ret++; } } long long save=ret; for(int i=0;i<n;i++) { if (str[i]=='E') { x++; } if (str[i]=='W') { x--; } if (str[i]=='N') { y++; } if (str[i]=='S') { y--; } s.insert(P(x,y)); } ret=0; for(auto now:s) { bool flag=true; for(int i=1;i<4;i++) { if (s.find(P(now.first+i/2,now.second+i%2))==s.end()) { flag=false; break; } } if (flag) { ret++; } } printf("%lld",save+(ret-save)*(k-5*n)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 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 | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 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 | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 468 KB | Output is correct |
29 | Correct | 8 ms | 980 KB | Output is correct |
30 | Correct | 12 ms | 1076 KB | Output is correct |
31 | Correct | 29 ms | 4244 KB | Output is correct |
32 | Correct | 13 ms | 1236 KB | Output is correct |
33 | Correct | 15 ms | 1508 KB | Output is correct |
34 | Correct | 17 ms | 1568 KB | Output is correct |
35 | Correct | 17 ms | 1528 KB | Output is correct |
36 | Correct | 14 ms | 1276 KB | Output is correct |
37 | Correct | 14 ms | 1492 KB | Output is correct |
38 | Correct | 15 ms | 1480 KB | Output is correct |
39 | Correct | 19 ms | 1504 KB | Output is correct |
40 | Correct | 14 ms | 1364 KB | Output is correct |
41 | Correct | 13 ms | 1288 KB | Output is correct |
42 | Correct | 12 ms | 1108 KB | Output is correct |
43 | Correct | 17 ms | 1552 KB | Output is correct |
44 | Correct | 16 ms | 1364 KB | Output is correct |
45 | Correct | 13 ms | 1224 KB | Output is correct |
46 | Correct | 20 ms | 2740 KB | Output is correct |
47 | Correct | 25 ms | 2740 KB | Output is correct |
48 | Correct | 27 ms | 5092 KB | Output is correct |
49 | Correct | 36 ms | 4980 KB | Output is correct |
50 | Correct | 40 ms | 5008 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 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 | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 4 ms | 596 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 3 ms | 392 KB | Output is correct |
31 | Correct | 2 ms | 436 KB | Output is correct |
32 | Correct | 4 ms | 596 KB | Output is correct |
33 | Correct | 3 ms | 596 KB | Output is correct |
34 | Correct | 4 ms | 468 KB | Output is correct |
35 | Correct | 4 ms | 596 KB | Output is correct |
36 | Correct | 3 ms | 516 KB | Output is correct |
37 | Correct | 5 ms | 688 KB | Output is correct |
38 | Correct | 3 ms | 468 KB | Output is correct |
39 | Correct | 3 ms | 440 KB | Output is correct |
40 | Correct | 1 ms | 212 KB | Output is correct |
41 | Correct | 3 ms | 340 KB | Output is correct |
42 | Correct | 1 ms | 304 KB | Output is correct |
43 | Correct | 4 ms | 564 KB | Output is correct |
44 | Correct | 3 ms | 340 KB | Output is correct |
45 | Correct | 3 ms | 468 KB | Output is correct |
46 | Correct | 1 ms | 340 KB | Output is correct |
47 | Correct | 3 ms | 340 KB | Output is correct |
48 | Correct | 3 ms | 596 KB | Output is correct |
49 | Correct | 1 ms | 340 KB | Output is correct |
50 | Correct | 4 ms | 884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 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 | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 468 KB | Output is correct |
29 | Correct | 8 ms | 980 KB | Output is correct |
30 | Correct | 12 ms | 1076 KB | Output is correct |
31 | Correct | 29 ms | 4244 KB | Output is correct |
32 | Correct | 13 ms | 1236 KB | Output is correct |
33 | Correct | 15 ms | 1508 KB | Output is correct |
34 | Correct | 17 ms | 1568 KB | Output is correct |
35 | Correct | 17 ms | 1528 KB | Output is correct |
36 | Correct | 14 ms | 1276 KB | Output is correct |
37 | Correct | 14 ms | 1492 KB | Output is correct |
38 | Correct | 15 ms | 1480 KB | Output is correct |
39 | Correct | 19 ms | 1504 KB | Output is correct |
40 | Correct | 14 ms | 1364 KB | Output is correct |
41 | Correct | 13 ms | 1288 KB | Output is correct |
42 | Correct | 12 ms | 1108 KB | Output is correct |
43 | Correct | 17 ms | 1552 KB | Output is correct |
44 | Correct | 16 ms | 1364 KB | Output is correct |
45 | Correct | 13 ms | 1224 KB | Output is correct |
46 | Correct | 20 ms | 2740 KB | Output is correct |
47 | Correct | 25 ms | 2740 KB | Output is correct |
48 | Correct | 27 ms | 5092 KB | Output is correct |
49 | Correct | 36 ms | 4980 KB | Output is correct |
50 | Correct | 40 ms | 5008 KB | Output is correct |
51 | Correct | 2 ms | 340 KB | Output is correct |
52 | Correct | 1 ms | 212 KB | Output is correct |
53 | Correct | 4 ms | 596 KB | Output is correct |
54 | Correct | 1 ms | 212 KB | Output is correct |
55 | Correct | 3 ms | 392 KB | Output is correct |
56 | Correct | 2 ms | 436 KB | Output is correct |
57 | Correct | 4 ms | 596 KB | Output is correct |
58 | Correct | 3 ms | 596 KB | Output is correct |
59 | Correct | 4 ms | 468 KB | Output is correct |
60 | Correct | 4 ms | 596 KB | Output is correct |
61 | Correct | 3 ms | 516 KB | Output is correct |
62 | Correct | 5 ms | 688 KB | Output is correct |
63 | Correct | 3 ms | 468 KB | Output is correct |
64 | Correct | 3 ms | 440 KB | Output is correct |
65 | Correct | 1 ms | 212 KB | Output is correct |
66 | Correct | 3 ms | 340 KB | Output is correct |
67 | Correct | 1 ms | 304 KB | Output is correct |
68 | Correct | 4 ms | 564 KB | Output is correct |
69 | Correct | 3 ms | 340 KB | Output is correct |
70 | Correct | 3 ms | 468 KB | Output is correct |
71 | Correct | 1 ms | 340 KB | Output is correct |
72 | Correct | 3 ms | 340 KB | Output is correct |
73 | Correct | 3 ms | 596 KB | Output is correct |
74 | Correct | 1 ms | 340 KB | Output is correct |
75 | Correct | 4 ms | 884 KB | Output is correct |
76 | Execution timed out | 1078 ms | 38312 KB | Time limit exceeded |
77 | Halted | 0 ms | 0 KB | - |