# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
973871 |
2024-05-02T12:10:05 Z |
Pekiban |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
23 ms |
2004 KB |
#include <bits/stdc++.h>
using namespace std;
int f(char c) {
return c == 'J' ? 2 : c == 'I';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> v[3];
for (int i = 0; i < n; ++i) {
char c;
cin >> c;
v[f(c)].push_back(i);
}
auto fnd = [&](int x, char c) {
return lower_bound(v[f(c)].begin(), v[f(c)].end(), x) - v[f(c)].begin();
};
int ans = 1e9;
for (int i = 0; i < n; ++i) {
int x = fnd(i, 'J');
if (x + k - 1 >= v[f('J')].size()) break;
int y = fnd(v[f('J')][x + k - 1], f('O'));
if (y + k - 1 >= v[f('O')].size()) break;
int z = fnd(v[f('O')][y + k - 1], 'I');
if (z + k - 1 >= v[f('I')].size()) break;
ans = min(ans, v[f('I')][z + k - 1] - i - 3*k + 1);
}
cout << (ans > n ? -1 : ans) << '\n';
}
Compilation message
ho_t2.cpp: In function 'int main()':
ho_t2.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | if (x + k - 1 >= v[f('J')].size()) break;
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
ho_t2.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | if (y + k - 1 >= v[f('O')].size()) break;
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
ho_t2.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if (z + k - 1 >= v[f('I')].size()) break;
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
456 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
452 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
600 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
456 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
452 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
600 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
19 ms |
1496 KB |
Output is correct |
37 |
Correct |
21 ms |
1688 KB |
Output is correct |
38 |
Correct |
21 ms |
1740 KB |
Output is correct |
39 |
Correct |
17 ms |
1748 KB |
Output is correct |
40 |
Correct |
7 ms |
1952 KB |
Output is correct |
41 |
Correct |
14 ms |
1756 KB |
Output is correct |
42 |
Correct |
23 ms |
1836 KB |
Output is correct |
43 |
Correct |
3 ms |
1368 KB |
Output is correct |
44 |
Correct |
3 ms |
1368 KB |
Output is correct |
45 |
Correct |
6 ms |
1748 KB |
Output is correct |
46 |
Correct |
4 ms |
2004 KB |
Output is correct |
47 |
Correct |
4 ms |
1840 KB |
Output is correct |
48 |
Correct |
4 ms |
1880 KB |
Output is correct |
49 |
Correct |
3 ms |
1236 KB |
Output is correct |
50 |
Correct |
4 ms |
1752 KB |
Output is correct |
51 |
Correct |
5 ms |
1752 KB |
Output is correct |
52 |
Correct |
4 ms |
1496 KB |
Output is correct |
53 |
Correct |
4 ms |
1736 KB |
Output is correct |
54 |
Correct |
8 ms |
1888 KB |
Output is correct |
55 |
Correct |
5 ms |
1888 KB |
Output is correct |
56 |
Correct |
3 ms |
1888 KB |
Output is correct |