# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
594080 |
2022-07-12T05:04:25 Z |
반딧불(#8432) |
None (JOI16_ho_t4) |
C++17 |
|
1000 ms |
18044 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int xx[]={0, 1, 0, -1}, yy[]={1, 0, -1, 0};
int n, k;
int arr[100002];
set<pair<int, int> > st;
ll ans[52];
int main(){
scanf("%d %d", &n, &k);
for(int i=1; i<=n; i++){
char c;
scanf(" %c", &c);
if(c == 'N') arr[i] = 0;
else if(c == 'E') arr[i] = 1;
else if(c == 'S') arr[i] = 2;
else arr[i] = 3;
}
st.insert(make_pair(0, 0));
int x = 0, y = 0;
for(int turn=1; turn<=50; turn++){
for(int i=1; i<=n; i++){
x += xx[arr[i]], y += yy[arr[i]];
st.insert(make_pair(x, y));
}
for(auto p: st){
if(st.find(make_pair(p.first, p.second+1)) == st.end() || st.find(make_pair(p.first+1, p.second)) == st.end() ||
st.find(make_pair(p.first+1, p.second+1)) == st.end()) continue;
ans[turn]++;
}
// printf("%d: %lld\n", turn, ans[turn]);
}
if(k<=50) printf("%lld", ans[k]);
else printf("%lld", ans[50] + (ans[50] - ans[49]) * (k - 50));
}
Compilation message
2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
2016_ho_t4.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf(" %c", &c);
| ~~~~~^~~~~~~~~~~
# |
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 |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
340 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
8 ms |
352 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
4 ms |
356 KB |
Output is correct |
18 |
Correct |
5 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
340 KB |
Output is correct |
23 |
Correct |
4 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
340 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 |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
340 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
8 ms |
352 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
4 ms |
356 KB |
Output is correct |
18 |
Correct |
5 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
340 KB |
Output is correct |
23 |
Correct |
4 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
340 KB |
Output is correct |
26 |
Correct |
20 ms |
532 KB |
Output is correct |
27 |
Correct |
237 ms |
2536 KB |
Output is correct |
28 |
Correct |
81 ms |
552 KB |
Output is correct |
29 |
Execution timed out |
1076 ms |
18044 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
340 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
8 ms |
352 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
4 ms |
356 KB |
Output is correct |
18 |
Correct |
5 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
340 KB |
Output is correct |
23 |
Correct |
4 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
340 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
5 ms |
340 KB |
Output is correct |
29 |
Correct |
4 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
7 ms |
340 KB |
Output is correct |
33 |
Correct |
4 ms |
340 KB |
Output is correct |
34 |
Correct |
4 ms |
340 KB |
Output is correct |
35 |
Correct |
5 ms |
340 KB |
Output is correct |
36 |
Correct |
3 ms |
340 KB |
Output is correct |
37 |
Correct |
6 ms |
340 KB |
Output is correct |
38 |
Correct |
3 ms |
340 KB |
Output is correct |
39 |
Correct |
3 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
2 ms |
340 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
5 ms |
340 KB |
Output is correct |
44 |
Correct |
2 ms |
212 KB |
Output is correct |
45 |
Correct |
4 ms |
340 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
4 ms |
340 KB |
Output is correct |
48 |
Correct |
5 ms |
340 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
4 ms |
340 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 |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
340 KB |
Output is correct |
8 |
Correct |
4 ms |
348 KB |
Output is correct |
9 |
Correct |
8 ms |
352 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
4 ms |
356 KB |
Output is correct |
18 |
Correct |
5 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
340 KB |
Output is correct |
23 |
Correct |
4 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
340 KB |
Output is correct |
26 |
Correct |
20 ms |
532 KB |
Output is correct |
27 |
Correct |
237 ms |
2536 KB |
Output is correct |
28 |
Correct |
81 ms |
552 KB |
Output is correct |
29 |
Execution timed out |
1076 ms |
18044 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |