# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
212523 | 2020-03-23T11:36:25 Z | DystoriaX | JJOOII 2 (JOI20_ho_t2) | C++14 | 18 ms | 2676 KB |
#include <bits/stdc++.h> using namespace std; int n, k; char s[200010]; vector<int> J, O, I; int lf[200010]; int ans = 1e9; int main(){ scanf("%d%d", &n, &k); scanf(" %s", s + 1); for(int i = 1; i <= n; i++){ if(s[i] == 'J') J.emplace_back(i); if(s[i] == 'O') O.emplace_back(i); if(s[i] == 'I') I.emplace_back(i); } for(int i = k - 1; i < (int) J.size(); i++){ lf[J[i]] = J[i - k + 1]; } for(int i = k - 1; i < (int) O.size(); i++){ auto it = upper_bound(J.begin(), J.end(), O[i - k + 1]); if(it == J.begin()) continue; --it; if(lf[*it] == 0) continue; lf[O[i]] = lf[*it]; } for(int i = k - 1; i < (int) I.size(); i++){ auto it = upper_bound(O.begin(), O.end(), I[i - k + 1]); if(it == O.begin()) continue; --it; if(lf[*it] == 0) continue; ans = min(ans, I[i] - lf[*it] + 1 - 3 * k); } if(ans == 1e9) ans = -1; printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 512 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 4 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 384 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 512 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 4 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 384 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 4 ms | 384 KB | Output is correct |
36 | Correct | 15 ms | 2300 KB | Output is correct |
37 | Correct | 18 ms | 2676 KB | Output is correct |
38 | Correct | 16 ms | 2416 KB | Output is correct |
39 | Correct | 18 ms | 2420 KB | Output is correct |
40 | Correct | 14 ms | 2160 KB | Output is correct |
41 | Correct | 15 ms | 2288 KB | Output is correct |
42 | Correct | 16 ms | 2676 KB | Output is correct |
43 | Correct | 10 ms | 1660 KB | Output is correct |
44 | Correct | 11 ms | 1788 KB | Output is correct |
45 | Correct | 14 ms | 2156 KB | Output is correct |
46 | Correct | 18 ms | 2152 KB | Output is correct |
47 | Correct | 14 ms | 2420 KB | Output is correct |
48 | Correct | 13 ms | 2288 KB | Output is correct |
49 | Correct | 10 ms | 1660 KB | Output is correct |
50 | Correct | 14 ms | 2160 KB | Output is correct |
51 | Correct | 15 ms | 2160 KB | Output is correct |
52 | Correct | 10 ms | 1636 KB | Output is correct |
53 | Correct | 10 ms | 1916 KB | Output is correct |
54 | Correct | 11 ms | 2168 KB | Output is correct |
55 | Correct | 8 ms | 2040 KB | Output is correct |
56 | Correct | 7 ms | 2040 KB | Output is correct |