Submission #774447

# Submission time Handle Problem Language Result Execution time Memory
774447 2023-07-05T18:03:15 Z stefanneagu JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
0 ms 212 KB
#include <iostream>
#include <vector>
using namespace std; 
int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> J, O, I;
    for(int i = 0; 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);
        } 
    }
    int ans = 1e9;
    for(int i = 0; i < J.size() - k + 1; i ++) {
        int pos_o = lower_bound(O.begin(), O.end(), J[i + k - 1]) - O.begin();
        if(pos_o <= O.size() - k + 1) {
            int pos_i = lower_bound(I.begin(), I.end(), O[pos_o + k - 1]) - I.begin();
            if(pos_i <= I.size() - k + 1) {
                int term = I[pos_i + k - 1];
                ans = min(ans, term - J[i] + 1 - 3 * k);
            }
        }
    }
    cout << ans;
    return 0;
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < J.size() - k + 1; i ++) {
      |                    ~~^~~~~~~~~~~~~~~~~~
ho_t2.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(pos_o <= O.size() - k + 1) {
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~
ho_t2.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             if(pos_i <= I.size() - k + 1) {
      |                ~~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -