# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
594126 |
2022-07-12T06:47:21 Z |
반딧불(#8432) |
영역 (JOI16_ho_t4) |
C++17 |
|
1000 ms |
66220 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int LIM = 300;
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);
| ~~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 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 |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 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 |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
7 ms |
1104 KB |
Output is correct |
30 |
Correct |
10 ms |
1740 KB |
Output is correct |
31 |
Correct |
16 ms |
1868 KB |
Output is correct |
32 |
Correct |
15 ms |
1740 KB |
Output is correct |
33 |
Correct |
15 ms |
1740 KB |
Output is correct |
34 |
Correct |
15 ms |
1740 KB |
Output is correct |
35 |
Correct |
15 ms |
1796 KB |
Output is correct |
36 |
Correct |
16 ms |
1820 KB |
Output is correct |
37 |
Correct |
20 ms |
1828 KB |
Output is correct |
38 |
Correct |
16 ms |
1744 KB |
Output is correct |
39 |
Correct |
17 ms |
1868 KB |
Output is correct |
40 |
Correct |
19 ms |
1836 KB |
Output is correct |
41 |
Correct |
13 ms |
1868 KB |
Output is correct |
42 |
Correct |
14 ms |
1856 KB |
Output is correct |
43 |
Correct |
15 ms |
1868 KB |
Output is correct |
44 |
Correct |
14 ms |
1740 KB |
Output is correct |
45 |
Correct |
13 ms |
1740 KB |
Output is correct |
46 |
Correct |
17 ms |
1816 KB |
Output is correct |
47 |
Correct |
15 ms |
1740 KB |
Output is correct |
48 |
Correct |
29 ms |
1784 KB |
Output is correct |
49 |
Correct |
12 ms |
1772 KB |
Output is correct |
50 |
Correct |
15 ms |
1740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 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 |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
3 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
500 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
3 ms |
476 KB |
Output is correct |
31 |
Correct |
3 ms |
476 KB |
Output is correct |
32 |
Correct |
4 ms |
476 KB |
Output is correct |
33 |
Correct |
3 ms |
476 KB |
Output is correct |
34 |
Correct |
3 ms |
476 KB |
Output is correct |
35 |
Correct |
3 ms |
476 KB |
Output is correct |
36 |
Correct |
3 ms |
468 KB |
Output is correct |
37 |
Correct |
3 ms |
476 KB |
Output is correct |
38 |
Correct |
3 ms |
480 KB |
Output is correct |
39 |
Correct |
2 ms |
476 KB |
Output is correct |
40 |
Correct |
2 ms |
476 KB |
Output is correct |
41 |
Correct |
4 ms |
476 KB |
Output is correct |
42 |
Correct |
3 ms |
528 KB |
Output is correct |
43 |
Correct |
4 ms |
476 KB |
Output is correct |
44 |
Correct |
3 ms |
476 KB |
Output is correct |
45 |
Correct |
3 ms |
476 KB |
Output is correct |
46 |
Correct |
3 ms |
480 KB |
Output is correct |
47 |
Correct |
3 ms |
480 KB |
Output is correct |
48 |
Correct |
3 ms |
476 KB |
Output is correct |
49 |
Correct |
2 ms |
484 KB |
Output is correct |
50 |
Correct |
1 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 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 |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
7 ms |
1104 KB |
Output is correct |
30 |
Correct |
10 ms |
1740 KB |
Output is correct |
31 |
Correct |
16 ms |
1868 KB |
Output is correct |
32 |
Correct |
15 ms |
1740 KB |
Output is correct |
33 |
Correct |
15 ms |
1740 KB |
Output is correct |
34 |
Correct |
15 ms |
1740 KB |
Output is correct |
35 |
Correct |
15 ms |
1796 KB |
Output is correct |
36 |
Correct |
16 ms |
1820 KB |
Output is correct |
37 |
Correct |
20 ms |
1828 KB |
Output is correct |
38 |
Correct |
16 ms |
1744 KB |
Output is correct |
39 |
Correct |
17 ms |
1868 KB |
Output is correct |
40 |
Correct |
19 ms |
1836 KB |
Output is correct |
41 |
Correct |
13 ms |
1868 KB |
Output is correct |
42 |
Correct |
14 ms |
1856 KB |
Output is correct |
43 |
Correct |
15 ms |
1868 KB |
Output is correct |
44 |
Correct |
14 ms |
1740 KB |
Output is correct |
45 |
Correct |
13 ms |
1740 KB |
Output is correct |
46 |
Correct |
17 ms |
1816 KB |
Output is correct |
47 |
Correct |
15 ms |
1740 KB |
Output is correct |
48 |
Correct |
29 ms |
1784 KB |
Output is correct |
49 |
Correct |
12 ms |
1772 KB |
Output is correct |
50 |
Correct |
15 ms |
1740 KB |
Output is correct |
51 |
Correct |
3 ms |
512 KB |
Output is correct |
52 |
Correct |
2 ms |
500 KB |
Output is correct |
53 |
Correct |
2 ms |
492 KB |
Output is correct |
54 |
Correct |
1 ms |
212 KB |
Output is correct |
55 |
Correct |
3 ms |
476 KB |
Output is correct |
56 |
Correct |
3 ms |
476 KB |
Output is correct |
57 |
Correct |
4 ms |
476 KB |
Output is correct |
58 |
Correct |
3 ms |
476 KB |
Output is correct |
59 |
Correct |
3 ms |
476 KB |
Output is correct |
60 |
Correct |
3 ms |
476 KB |
Output is correct |
61 |
Correct |
3 ms |
468 KB |
Output is correct |
62 |
Correct |
3 ms |
476 KB |
Output is correct |
63 |
Correct |
3 ms |
480 KB |
Output is correct |
64 |
Correct |
2 ms |
476 KB |
Output is correct |
65 |
Correct |
2 ms |
476 KB |
Output is correct |
66 |
Correct |
4 ms |
476 KB |
Output is correct |
67 |
Correct |
3 ms |
528 KB |
Output is correct |
68 |
Correct |
4 ms |
476 KB |
Output is correct |
69 |
Correct |
3 ms |
476 KB |
Output is correct |
70 |
Correct |
3 ms |
476 KB |
Output is correct |
71 |
Correct |
3 ms |
480 KB |
Output is correct |
72 |
Correct |
3 ms |
480 KB |
Output is correct |
73 |
Correct |
3 ms |
476 KB |
Output is correct |
74 |
Correct |
2 ms |
484 KB |
Output is correct |
75 |
Correct |
1 ms |
544 KB |
Output is correct |
76 |
Correct |
517 ms |
49488 KB |
Output is correct |
77 |
Correct |
377 ms |
49720 KB |
Output is correct |
78 |
Execution timed out |
1085 ms |
66220 KB |
Time limit exceeded |
79 |
Halted |
0 ms |
0 KB |
- |