Submission #575074

# Submission time Handle Problem Language Result Execution time Memory
575074 2022-06-09T15:32:27 Z pokmui9909 JJOOII 2 (JOI20_ho_t2) C++17
100 / 100
25 ms 3232 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll N, K;
string S;
vector<ll> J, O, I;

int main(){
    cin.tie(0) -> sync_with_stdio(false);

    cin >> N >> K >> S;
    S = " " + S;
    for(ll i = 1; i <= N; i++){
        if(S[i] == 'J') J.push_back(i);
        if(S[i] == 'O') O.push_back(i);
        if(S[i] == 'I') I.push_back(i);
    }
    ll t = 1e18;
    for(ll i = 1; i <= N; i++){
        ll p = lower_bound(J.begin(), J.end(), i) - J.begin() + K - 1;
        if(p >= J.size()) continue;

        ll q = lower_bound(O.begin(), O.end(), J[p]) - O.begin() + K - 1;
        if(q >= O.size()) continue;

        ll r = lower_bound(I.begin(), I.end(), O[q]) - I.begin() + K - 1;
        if(r >= I.size()) continue;

        t = min(t, I[r] - i + 1 - 3 * K);
    }
    cout << (t == 1e18 ? -1 : t);
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:22:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(p >= J.size()) continue;
      |            ~~^~~~~~~~~~~
ho_t2.cpp:25:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(q >= O.size()) continue;
      |            ~~^~~~~~~~~~~
ho_t2.cpp:28:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if(r >= I.size()) continue;
      |            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 324 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 1 ms 280 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 316 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 1 ms 340 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 324 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 1 ms 280 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 316 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 1 ms 340 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 22 ms 2584 KB Output is correct
37 Correct 24 ms 3088 KB Output is correct
38 Correct 25 ms 2928 KB Output is correct
39 Correct 25 ms 2924 KB Output is correct
40 Correct 20 ms 2844 KB Output is correct
41 Correct 21 ms 3220 KB Output is correct
42 Correct 25 ms 2844 KB Output is correct
43 Correct 11 ms 1868 KB Output is correct
44 Correct 13 ms 2380 KB Output is correct
45 Correct 17 ms 3220 KB Output is correct
46 Correct 19 ms 3212 KB Output is correct
47 Correct 17 ms 3220 KB Output is correct
48 Correct 19 ms 3220 KB Output is correct
49 Correct 12 ms 2080 KB Output is correct
50 Correct 18 ms 3232 KB Output is correct
51 Correct 18 ms 2840 KB Output is correct
52 Correct 13 ms 2716 KB Output is correct
53 Correct 11 ms 2708 KB Output is correct
54 Correct 12 ms 3224 KB Output is correct
55 Correct 10 ms 3224 KB Output is correct
56 Correct 9 ms 3216 KB Output is correct