# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
586196 | 2022-06-30T04:31:07 Z | hibiki | JJOOII 2 (JOI20_ho_t2) | C++11 | 6 ms | 2772 KB |
#include<bits/stdc++.h> using namespace std; #define pb push_back #define sz(x) (int)x.size() int n, k; int link[200005]; vector<int> idx[10]; char s[200005]; int get_ty(char x) { if(x == 'J') return 1; if(x == 'O') return 2; if(x == 'I') return 3; exit(-1); } int main() { scanf("%d %d",&n,&k); scanf("%s",s); for(int i = 0; i < n; i++) { int ty = get_ty(s[i]); link[i] = sz(idx[ty - 1]) - 1; idx[ty].pb(i); } int ans = 1e9; for(int bi = 0; bi < sz(idx[3]); bi++) { int fi = bi - k + 1; if(fi < 0) continue; int bo = link[idx[3][fi]]; int fo = bo - k + 1; if(fo < 0) continue; int bj = link[idx[2][fo]]; int fj = bj - k + 1; if(fj < 0) continue; ans = min(ans, idx[3][bi] - idx[1][fj] + 1 - 3 * k); } if(ans == 1e9) ans = -1; printf("%d\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 316 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 316 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 336 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 308 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 | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 308 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 316 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 336 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 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 | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 308 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 | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 308 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 5 ms | 2256 KB | Output is correct |
37 | Correct | 6 ms | 2544 KB | Output is correct |
38 | Correct | 6 ms | 2720 KB | Output is correct |
39 | Correct | 6 ms | 2668 KB | Output is correct |
40 | Correct | 5 ms | 2600 KB | Output is correct |
41 | Correct | 5 ms | 2640 KB | Output is correct |
42 | Correct | 5 ms | 2624 KB | Output is correct |
43 | Correct | 3 ms | 1620 KB | Output is correct |
44 | Correct | 4 ms | 1860 KB | Output is correct |
45 | Correct | 5 ms | 2772 KB | Output is correct |
46 | Correct | 5 ms | 2620 KB | Output is correct |
47 | Correct | 5 ms | 2640 KB | Output is correct |
48 | Correct | 5 ms | 2764 KB | Output is correct |
49 | Correct | 3 ms | 1744 KB | Output is correct |
50 | Correct | 6 ms | 2644 KB | Output is correct |
51 | Correct | 5 ms | 2640 KB | Output is correct |
52 | Correct | 4 ms | 2256 KB | Output is correct |
53 | Correct | 6 ms | 2644 KB | Output is correct |
54 | Correct | 4 ms | 2716 KB | Output is correct |
55 | Correct | 4 ms | 2768 KB | Output is correct |
56 | Correct | 4 ms | 2768 KB | Output is correct |