# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
594127 |
2022-07-12T06:48:11 Z |
반딧불(#8432) |
None (JOI16_ho_t4) |
C++17 |
|
390 ms |
32232 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int LIM = 100;
const int xx[]={0, 1, 0, -1}, yy[]={1, 0, -1, 0};
int n, k;
int arr[100002];
ll ans[52];
ll getAns(ll k){
vector<pair<int, int> > vec;
int x=0, y=0;
vec.push_back(make_pair(x, y));
for(int turn=1; turn<=k; turn++){
for(int i=1; i<=n; i++){
x+=xx[arr[i]], y+=yy[arr[i]];
vec.push_back(make_pair(x, y));
}
}
sort(vec.begin(), vec.end());
vec.erase(unique(vec.begin(), vec.end()), vec.end());
int cnt = 0;
for(int i=0; i<(int)vec.size()-1; i++){
if(vec[i+1].first != vec[i].first || vec[i+1].second != vec[i].second+1) continue;
auto it = lower_bound(vec.begin(), vec.end(), make_pair(vec[i].first+1, vec[i].second));
if(it == vec.end() || next(it) == vec.end()) continue;
++it;
if(it->second != vec[i].second+1 || it->first != vec[i].first+1) continue;
cnt++;
}
return cnt;
}
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;
}
if(k<=LIM){
printf("%lld", getAns(k));
}
else{
ll ansL = getAns(LIM), ansL1 = getAns(LIM-1);
printf("%lld", ansL + (ansL - ansL1) * (k - LIM));
}
}
Compilation message
2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
2016_ho_t4.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf(" %c", &c);
| ~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 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 |
1 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 |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 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 |
1 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 |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
596 KB |
Output is correct |
29 |
Correct |
11 ms |
1104 KB |
Output is correct |
30 |
Correct |
12 ms |
1740 KB |
Output is correct |
31 |
Correct |
15 ms |
1740 KB |
Output is correct |
32 |
Correct |
15 ms |
1868 KB |
Output is correct |
33 |
Correct |
18 ms |
1868 KB |
Output is correct |
34 |
Correct |
15 ms |
1780 KB |
Output is correct |
35 |
Correct |
18 ms |
1868 KB |
Output is correct |
36 |
Correct |
50 ms |
1848 KB |
Output is correct |
37 |
Correct |
16 ms |
1796 KB |
Output is correct |
38 |
Correct |
21 ms |
1740 KB |
Output is correct |
39 |
Correct |
23 ms |
1852 KB |
Output is correct |
40 |
Correct |
21 ms |
1740 KB |
Output is correct |
41 |
Correct |
18 ms |
1740 KB |
Output is correct |
42 |
Correct |
13 ms |
1868 KB |
Output is correct |
43 |
Correct |
19 ms |
1740 KB |
Output is correct |
44 |
Correct |
15 ms |
1812 KB |
Output is correct |
45 |
Correct |
13 ms |
1740 KB |
Output is correct |
46 |
Correct |
16 ms |
1740 KB |
Output is correct |
47 |
Correct |
16 ms |
1740 KB |
Output is correct |
48 |
Correct |
15 ms |
1740 KB |
Output is correct |
49 |
Correct |
10 ms |
1740 KB |
Output is correct |
50 |
Correct |
12 ms |
1772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 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 |
1 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 |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
2 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
340 KB |
Output is correct |
38 |
Correct |
1 ms |
340 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
372 KB |
Output is correct |
41 |
Correct |
1 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
2 ms |
348 KB |
Output is correct |
44 |
Correct |
1 ms |
340 KB |
Output is correct |
45 |
Correct |
1 ms |
340 KB |
Output is correct |
46 |
Correct |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
2 ms |
340 KB |
Output is correct |
48 |
Correct |
2 ms |
340 KB |
Output is correct |
49 |
Correct |
1 ms |
340 KB |
Output is correct |
50 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 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 |
1 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 |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
596 KB |
Output is correct |
29 |
Correct |
11 ms |
1104 KB |
Output is correct |
30 |
Correct |
12 ms |
1740 KB |
Output is correct |
31 |
Correct |
15 ms |
1740 KB |
Output is correct |
32 |
Correct |
15 ms |
1868 KB |
Output is correct |
33 |
Correct |
18 ms |
1868 KB |
Output is correct |
34 |
Correct |
15 ms |
1780 KB |
Output is correct |
35 |
Correct |
18 ms |
1868 KB |
Output is correct |
36 |
Correct |
50 ms |
1848 KB |
Output is correct |
37 |
Correct |
16 ms |
1796 KB |
Output is correct |
38 |
Correct |
21 ms |
1740 KB |
Output is correct |
39 |
Correct |
23 ms |
1852 KB |
Output is correct |
40 |
Correct |
21 ms |
1740 KB |
Output is correct |
41 |
Correct |
18 ms |
1740 KB |
Output is correct |
42 |
Correct |
13 ms |
1868 KB |
Output is correct |
43 |
Correct |
19 ms |
1740 KB |
Output is correct |
44 |
Correct |
15 ms |
1812 KB |
Output is correct |
45 |
Correct |
13 ms |
1740 KB |
Output is correct |
46 |
Correct |
16 ms |
1740 KB |
Output is correct |
47 |
Correct |
16 ms |
1740 KB |
Output is correct |
48 |
Correct |
15 ms |
1740 KB |
Output is correct |
49 |
Correct |
10 ms |
1740 KB |
Output is correct |
50 |
Correct |
12 ms |
1772 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
1 ms |
340 KB |
Output is correct |
53 |
Correct |
1 ms |
340 KB |
Output is correct |
54 |
Correct |
1 ms |
212 KB |
Output is correct |
55 |
Correct |
1 ms |
340 KB |
Output is correct |
56 |
Correct |
1 ms |
340 KB |
Output is correct |
57 |
Correct |
2 ms |
340 KB |
Output is correct |
58 |
Correct |
1 ms |
340 KB |
Output is correct |
59 |
Correct |
2 ms |
340 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
1 ms |
340 KB |
Output is correct |
62 |
Correct |
1 ms |
340 KB |
Output is correct |
63 |
Correct |
1 ms |
340 KB |
Output is correct |
64 |
Correct |
1 ms |
340 KB |
Output is correct |
65 |
Correct |
1 ms |
372 KB |
Output is correct |
66 |
Correct |
1 ms |
340 KB |
Output is correct |
67 |
Correct |
1 ms |
340 KB |
Output is correct |
68 |
Correct |
2 ms |
348 KB |
Output is correct |
69 |
Correct |
1 ms |
340 KB |
Output is correct |
70 |
Correct |
1 ms |
340 KB |
Output is correct |
71 |
Correct |
1 ms |
340 KB |
Output is correct |
72 |
Correct |
2 ms |
340 KB |
Output is correct |
73 |
Correct |
2 ms |
340 KB |
Output is correct |
74 |
Correct |
1 ms |
340 KB |
Output is correct |
75 |
Correct |
1 ms |
344 KB |
Output is correct |
76 |
Correct |
178 ms |
14732 KB |
Output is correct |
77 |
Correct |
138 ms |
14680 KB |
Output is correct |
78 |
Incorrect |
390 ms |
32232 KB |
Output isn't correct |
79 |
Halted |
0 ms |
0 KB |
- |