# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815699 | 2023-08-08T19:03:26 Z | anton | JJOOII 2 (JOI20_ho_t2) | C++17 | 10 ms | 6964 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> const int MAX_N = 2*1e5; const int INF = 1e18; int n, k; string s; int prev2[3][MAX_N]; void find(char c, int j){ vector<int> oc; for(int i = 0; i<n; i++){ if(s[i] == c){ oc.push_back(i); } if(oc.size()>=k){ prev2[j][i] = oc[oc.size()-k]; } else{ prev2[j][i] = -INF; } //cout<<prev2[j][i]<<" "; } cout<<endl; } signed main(){ cin>>n>>k; cin>>s; find('J', 0); find('O', 1); find('I', 2); int res= INF; for(int i= 0; i<n; i++){ int cur = i; for(int j = 2; j>=0; j--){ if(cur>=0){ cur = prev2[j][cur]; } } res = min(res, i-cur+1); } if(res>=INF){ cout<<-1<<endl; return 0; } cout<<res-3*k<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 308 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 308 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 308 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 308 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 | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 304 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 304 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 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 | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 308 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 308 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 | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 304 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 304 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 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 | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 308 KB | Output is correct |
36 | Correct | 8 ms | 6028 KB | Output is correct |
37 | Correct | 9 ms | 6856 KB | Output is correct |
38 | Correct | 9 ms | 6908 KB | Output is correct |
39 | Correct | 9 ms | 6344 KB | Output is correct |
40 | Correct | 10 ms | 6912 KB | Output is correct |
41 | Correct | 9 ms | 6928 KB | Output is correct |
42 | Correct | 9 ms | 6852 KB | Output is correct |
43 | Correct | 6 ms | 4280 KB | Output is correct |
44 | Correct | 7 ms | 5172 KB | Output is correct |
45 | Correct | 9 ms | 6924 KB | Output is correct |
46 | Correct | 9 ms | 6964 KB | Output is correct |
47 | Correct | 10 ms | 6940 KB | Output is correct |
48 | Correct | 9 ms | 6852 KB | Output is correct |
49 | Correct | 6 ms | 4516 KB | Output is correct |
50 | Correct | 9 ms | 6836 KB | Output is correct |
51 | Correct | 9 ms | 6852 KB | Output is correct |
52 | Correct | 8 ms | 6124 KB | Output is correct |
53 | Correct | 9 ms | 6852 KB | Output is correct |
54 | Correct | 8 ms | 6848 KB | Output is correct |
55 | Correct | 7 ms | 6848 KB | Output is correct |
56 | Correct | 7 ms | 6952 KB | Output is correct |