# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
707726 |
2023-03-09T21:22:31 Z |
rainboy |
JJOOII 2 (JOI20_ho_t2) |
C |
|
5 ms |
2504 KB |
#include <stdio.h>
#include <string.h>
#define N 200000
#define INF 0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
char *joi = "JOI";
int main() {
static char cc[N + 1];
static int qu[N], jj[N + 1], jj_[N + 1];
int n, cnt, k, i, h, ans;
scanf("%d%d%s", &n, &k, cc);
for (i = 0; i <= n; i++)
jj[i] = i;
for (h = 2; h >= 0; h--) {
cnt = 0;
jj_[n] = -1;
for (i = n - 1; i >= 0; i--) {
if (cc[i] == joi[h])
qu[cnt++] = i;
jj_[i] = cnt >= k ? jj[qu[cnt - k] + 1] : -1;
}
memcpy(jj, jj_, (n + 1) * sizeof *jj_);
}
ans = INF;
for (i = 0; i < n; i++)
if (jj[i] != -1)
ans = min(ans, jj[i] - i - k * 3);
if (ans == INF)
ans = -1;
printf("%d\n", ans);
return 0;
}
Compilation message
ho_t2.c: In function 'main':
ho_t2.c:16:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d%d%s", &n, &k, cc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
296 KB |
Output is correct |
13 |
Correct |
1 ms |
292 KB |
Output is correct |
14 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
296 KB |
Output is correct |
13 |
Correct |
1 ms |
292 KB |
Output is correct |
14 |
Correct |
1 ms |
296 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
292 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
340 KB |
Output is correct |
29 |
Correct |
0 ms |
296 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 |
292 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
296 KB |
Output is correct |
13 |
Correct |
1 ms |
292 KB |
Output is correct |
14 |
Correct |
1 ms |
296 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
292 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
340 KB |
Output is correct |
29 |
Correct |
0 ms |
296 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 |
292 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
4 ms |
2252 KB |
Output is correct |
37 |
Correct |
5 ms |
2500 KB |
Output is correct |
38 |
Correct |
5 ms |
2480 KB |
Output is correct |
39 |
Correct |
5 ms |
2392 KB |
Output is correct |
40 |
Correct |
5 ms |
2480 KB |
Output is correct |
41 |
Correct |
5 ms |
2484 KB |
Output is correct |
42 |
Correct |
5 ms |
2504 KB |
Output is correct |
43 |
Correct |
4 ms |
1620 KB |
Output is correct |
44 |
Correct |
4 ms |
2004 KB |
Output is correct |
45 |
Correct |
5 ms |
2392 KB |
Output is correct |
46 |
Correct |
5 ms |
2388 KB |
Output is correct |
47 |
Correct |
5 ms |
2388 KB |
Output is correct |
48 |
Correct |
5 ms |
2388 KB |
Output is correct |
49 |
Correct |
3 ms |
1748 KB |
Output is correct |
50 |
Correct |
5 ms |
2484 KB |
Output is correct |
51 |
Correct |
5 ms |
2484 KB |
Output is correct |
52 |
Correct |
5 ms |
2360 KB |
Output is correct |
53 |
Correct |
5 ms |
2484 KB |
Output is correct |
54 |
Correct |
3 ms |
2388 KB |
Output is correct |
55 |
Correct |
3 ms |
2388 KB |
Output is correct |
56 |
Correct |
3 ms |
2468 KB |
Output is correct |