# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
594078 |
2022-07-12T05:03:01 Z |
박상훈(#8431) |
None (JOI16_ho_t4) |
C++17 |
|
1000 ms |
45216 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
set<pair<int, int>> visited, made;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1}, cc[1234];
char s[100100];
bool ok(int x, int y){
return visited.find(make_pair(x, y))!=visited.end();
}
int _make(int x, int y){
if (made.find(make_pair(x, y))!=made.end()) return 0;
if (ok(x, y) && ok(x+1, y) && ok(x, y+1) && ok(x+1, y+1)){
made.emplace(x, y);
return 1;
}
return 0;
}
int main(){
int n, k;
scanf("%d %d", &n, &k);
scanf("%s", s+1);
cc['E'] = 0, cc['S'] = 1, cc['W'] = 2, cc['N'] = 3;
int prv = 1e9, x = 0, y = 0, c = 0;
ll ans = 0;
visited.emplace(0, 0);
while(k){
int cnt = 0;
for (int i=1;i<=n;i++){
x += dx[cc[s[i]]], y += dy[cc[s[i]]];
visited.emplace(x, y);
cnt += _make(x, y);
cnt += _make(x, y-1);
cnt += _make(x-1, y);
cnt += _make(x-1, y-1);
}
ans += cnt;
--k;
++c;
if (c>100) break;
//if (prv==cnt) break;
prv = cnt;
//printf("%d\n", cnt);
}
ans += (ll)prv * k;
printf("%lld\n", ans);
return 0;
}
Compilation message
2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:36:27: warning: array subscript has type 'char' [-Wchar-subscripts]
36 | x += dx[cc[s[i]]], y += dy[cc[s[i]]];
| ~~~^
2016_ho_t4.cpp:36:46: warning: array subscript has type 'char' [-Wchar-subscripts]
36 | x += dx[cc[s[i]]], y += dy[cc[s[i]]];
| ~~~^
2016_ho_t4.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
2016_ho_t4.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | scanf("%s", s+1);
| ~~~~~^~~~~~~~~~~
# |
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 |
0 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 |
212 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 |
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 |
212 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 |
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 |
0 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 |
212 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 |
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 |
212 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 |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
3 ms |
340 KB |
Output is correct |
28 |
Correct |
8 ms |
596 KB |
Output is correct |
29 |
Correct |
29 ms |
1360 KB |
Output is correct |
30 |
Correct |
37 ms |
1528 KB |
Output is correct |
31 |
Correct |
56 ms |
4428 KB |
Output is correct |
32 |
Correct |
60 ms |
1996 KB |
Output is correct |
33 |
Correct |
58 ms |
2312 KB |
Output is correct |
34 |
Correct |
65 ms |
2400 KB |
Output is correct |
35 |
Correct |
54 ms |
2224 KB |
Output is correct |
36 |
Correct |
53 ms |
2012 KB |
Output is correct |
37 |
Correct |
55 ms |
2252 KB |
Output is correct |
38 |
Correct |
61 ms |
2148 KB |
Output is correct |
39 |
Correct |
71 ms |
2280 KB |
Output is correct |
40 |
Correct |
54 ms |
2008 KB |
Output is correct |
41 |
Correct |
49 ms |
1876 KB |
Output is correct |
42 |
Correct |
48 ms |
1664 KB |
Output is correct |
43 |
Correct |
61 ms |
2404 KB |
Output is correct |
44 |
Correct |
59 ms |
2176 KB |
Output is correct |
45 |
Correct |
52 ms |
1836 KB |
Output is correct |
46 |
Correct |
57 ms |
2648 KB |
Output is correct |
47 |
Correct |
68 ms |
2644 KB |
Output is correct |
48 |
Correct |
63 ms |
5068 KB |
Output is correct |
49 |
Correct |
73 ms |
5040 KB |
Output is correct |
50 |
Correct |
77 ms |
4996 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 |
0 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 |
212 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 |
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 |
212 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 |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
340 KB |
Output is correct |
32 |
Correct |
4 ms |
540 KB |
Output is correct |
33 |
Correct |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
3 ms |
340 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
37 |
Correct |
3 ms |
468 KB |
Output is correct |
38 |
Correct |
3 ms |
340 KB |
Output is correct |
39 |
Correct |
3 ms |
340 KB |
Output is correct |
40 |
Correct |
2 ms |
212 KB |
Output is correct |
41 |
Correct |
3 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
4 ms |
468 KB |
Output is correct |
44 |
Correct |
2 ms |
340 KB |
Output is correct |
45 |
Correct |
2 ms |
340 KB |
Output is correct |
46 |
Correct |
2 ms |
340 KB |
Output is correct |
47 |
Correct |
3 ms |
340 KB |
Output is correct |
48 |
Correct |
3 ms |
468 KB |
Output is correct |
49 |
Correct |
3 ms |
212 KB |
Output is correct |
50 |
Correct |
3 ms |
468 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 |
0 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 |
212 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 |
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 |
212 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 |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
3 ms |
340 KB |
Output is correct |
28 |
Correct |
8 ms |
596 KB |
Output is correct |
29 |
Correct |
29 ms |
1360 KB |
Output is correct |
30 |
Correct |
37 ms |
1528 KB |
Output is correct |
31 |
Correct |
56 ms |
4428 KB |
Output is correct |
32 |
Correct |
60 ms |
1996 KB |
Output is correct |
33 |
Correct |
58 ms |
2312 KB |
Output is correct |
34 |
Correct |
65 ms |
2400 KB |
Output is correct |
35 |
Correct |
54 ms |
2224 KB |
Output is correct |
36 |
Correct |
53 ms |
2012 KB |
Output is correct |
37 |
Correct |
55 ms |
2252 KB |
Output is correct |
38 |
Correct |
61 ms |
2148 KB |
Output is correct |
39 |
Correct |
71 ms |
2280 KB |
Output is correct |
40 |
Correct |
54 ms |
2008 KB |
Output is correct |
41 |
Correct |
49 ms |
1876 KB |
Output is correct |
42 |
Correct |
48 ms |
1664 KB |
Output is correct |
43 |
Correct |
61 ms |
2404 KB |
Output is correct |
44 |
Correct |
59 ms |
2176 KB |
Output is correct |
45 |
Correct |
52 ms |
1836 KB |
Output is correct |
46 |
Correct |
57 ms |
2648 KB |
Output is correct |
47 |
Correct |
68 ms |
2644 KB |
Output is correct |
48 |
Correct |
63 ms |
5068 KB |
Output is correct |
49 |
Correct |
73 ms |
5040 KB |
Output is correct |
50 |
Correct |
77 ms |
4996 KB |
Output is correct |
51 |
Correct |
3 ms |
340 KB |
Output is correct |
52 |
Correct |
1 ms |
212 KB |
Output is correct |
53 |
Correct |
3 ms |
468 KB |
Output is correct |
54 |
Correct |
1 ms |
340 KB |
Output is correct |
55 |
Correct |
2 ms |
340 KB |
Output is correct |
56 |
Correct |
3 ms |
340 KB |
Output is correct |
57 |
Correct |
4 ms |
540 KB |
Output is correct |
58 |
Correct |
3 ms |
468 KB |
Output is correct |
59 |
Correct |
3 ms |
340 KB |
Output is correct |
60 |
Correct |
3 ms |
468 KB |
Output is correct |
61 |
Correct |
2 ms |
340 KB |
Output is correct |
62 |
Correct |
3 ms |
468 KB |
Output is correct |
63 |
Correct |
3 ms |
340 KB |
Output is correct |
64 |
Correct |
3 ms |
340 KB |
Output is correct |
65 |
Correct |
2 ms |
212 KB |
Output is correct |
66 |
Correct |
3 ms |
340 KB |
Output is correct |
67 |
Correct |
1 ms |
212 KB |
Output is correct |
68 |
Correct |
4 ms |
468 KB |
Output is correct |
69 |
Correct |
2 ms |
340 KB |
Output is correct |
70 |
Correct |
2 ms |
340 KB |
Output is correct |
71 |
Correct |
2 ms |
340 KB |
Output is correct |
72 |
Correct |
3 ms |
340 KB |
Output is correct |
73 |
Correct |
3 ms |
468 KB |
Output is correct |
74 |
Correct |
3 ms |
212 KB |
Output is correct |
75 |
Correct |
3 ms |
468 KB |
Output is correct |
76 |
Correct |
446 ms |
6856 KB |
Output is correct |
77 |
Correct |
270 ms |
464 KB |
Output is correct |
78 |
Execution timed out |
1088 ms |
45216 KB |
Time limit exceeded |
79 |
Halted |
0 ms |
0 KB |
- |