# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023786 | 2024-07-15T06:36:57 Z | vjudge1 | JJOOII 2 (JOI20_ho_t2) | C++17 | 2000 ms | 984 KB |
#include <bits/stdc++.h> #define int long long #define pb push_back #define f first #define s second #pragma GCC optimize("O3") #pragma GCC target("avx2") const int inf = 1e9; using namespace std; void solve() { int n, k; cin >> n >> k; string s; cin >> s; int ans = inf; string s2 = ""; for(int i = 0;i < k;i++) { s2 += 'J'; } for(int i = 0;i < k;i++) { s2 += 'O'; } for(int i = 0;i < k;i++) { s2 += 'I'; } for(int l = 0 ;l < s.size() ; l++) { int cnt1 = 0, cnt2 = 0; for(int r = l;r < s.size();r++) { if(s[r] == s2[cnt1]) { cnt1++; } else { cnt2++; } if(cnt1 == s2.size()) { ans = min(ans, cnt2); break; } } } if (ans == inf) ans = -1; cout << ans; } signed main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); int t = 1; //cin >> t; while (t--) { solve(); } }
Compilation message
# | 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 | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 456 KB | Output is correct |
8 | Correct | 1 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 | 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 | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 456 KB | Output is correct |
8 | Correct | 1 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 | 348 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 360 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 3 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 4 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 464 KB | Output is correct |
27 | Correct | 4 ms | 344 KB | Output is correct |
28 | Correct | 5 ms | 348 KB | Output is correct |
29 | Correct | 4 ms | 348 KB | Output is correct |
30 | Correct | 4 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 4 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 460 KB | Output is correct |
34 | Correct | 3 ms | 344 KB | Output is correct |
35 | Correct | 3 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 | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 456 KB | Output is correct |
8 | Correct | 1 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 | 348 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 360 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 3 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 4 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 464 KB | Output is correct |
27 | Correct | 4 ms | 344 KB | Output is correct |
28 | Correct | 5 ms | 348 KB | Output is correct |
29 | Correct | 4 ms | 348 KB | Output is correct |
30 | Correct | 4 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 4 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 460 KB | Output is correct |
34 | Correct | 3 ms | 344 KB | Output is correct |
35 | Correct | 3 ms | 344 KB | Output is correct |
36 | Correct | 3 ms | 856 KB | Output is correct |
37 | Correct | 5 ms | 856 KB | Output is correct |
38 | Correct | 3 ms | 984 KB | Output is correct |
39 | Execution timed out | 2057 ms | 860 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |