# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
896823 |
2024-01-02T09:04:49 Z |
ace5 |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
20 ms |
3312 KB |
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
vector<vector<int>> b(26);
int n;
int go(int pos,int k,int c)
{
if(pos == n)
return n;
int ind = lower_bound(b[c].begin(),b[c].end(),pos)-b[c].begin() + k - 1;
return (ind < b[c].size() ? b[c][ind] : n);
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int k;
cin >> n >> k;
string s;
cin >> s;
for(int j = 0;j < n;++j)
{
b[s[j]-'A'].push_back(j);
}
int ans = n+1;
for(int j = 0;j < n;++j)
{
int lp = go(go(go(j,k,'J'-'A'),k,'O'-'A'),k,'I'-'A');
if(lp != n)
{
ans = min(ans,lp-j+1);
}
}
cout << (ans == n+1 ? -1 : ans-k*3);
return 0;
}
Compilation message
ho_t2.cpp: In function 'int64_t go(int64_t, int64_t, int64_t)':
ho_t2.cpp:16:17: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | return (ind < b[c].size() ? b[c][ind] : n);
| ~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
360 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 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 |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
360 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 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 |
344 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
452 KB |
Output is correct |
29 |
Correct |
0 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 |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
360 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 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 |
344 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
452 KB |
Output is correct |
29 |
Correct |
0 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 |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
17 ms |
2508 KB |
Output is correct |
37 |
Correct |
20 ms |
3024 KB |
Output is correct |
38 |
Correct |
19 ms |
2876 KB |
Output is correct |
39 |
Correct |
18 ms |
2984 KB |
Output is correct |
40 |
Correct |
16 ms |
3024 KB |
Output is correct |
41 |
Correct |
17 ms |
3028 KB |
Output is correct |
42 |
Correct |
18 ms |
3028 KB |
Output is correct |
43 |
Correct |
9 ms |
1972 KB |
Output is correct |
44 |
Correct |
11 ms |
2256 KB |
Output is correct |
45 |
Correct |
15 ms |
2964 KB |
Output is correct |
46 |
Correct |
15 ms |
3220 KB |
Output is correct |
47 |
Correct |
15 ms |
3028 KB |
Output is correct |
48 |
Correct |
15 ms |
2996 KB |
Output is correct |
49 |
Correct |
10 ms |
2004 KB |
Output is correct |
50 |
Correct |
15 ms |
2988 KB |
Output is correct |
51 |
Correct |
15 ms |
3028 KB |
Output is correct |
52 |
Correct |
10 ms |
2504 KB |
Output is correct |
53 |
Correct |
11 ms |
2896 KB |
Output is correct |
54 |
Correct |
10 ms |
3312 KB |
Output is correct |
55 |
Correct |
9 ms |
3296 KB |
Output is correct |
56 |
Correct |
8 ms |
3296 KB |
Output is correct |