답안 #1115756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115756 2024-11-20T23:33:19 Z staszic_ojuz JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;

int n, k, J[200001], O[200001], I[200001];
vector<int> J_gdzie, O_gdzie, I_gdzie;
string word;



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    cin >> word;
    for(int i = 0; i < n; i++){
        //cout << J[i] << " " << I[i] << " " << O[i] << " " << word[i] << endl;
        J[i] = J[i - 1];
        O[i] = O[i - 1];
        I[i] = I[i - 1];
        if(word[i] == 'J'){
            J_gdzie.push_back(i);
            J[i]++;
        }
        if(word[i] == 'O'){
            O_gdzie.push_back(i);
            O[i]++;
        }
        if(word[i] == 'I'){
            I_gdzie.push_back(i);
            I[i]++;
        }
    }
    for(int i = 0; i < n; i++){
        //cout << J[i] << " " << O[i] << " " << I[i] << endl;
    }
    int wynik = 200001;
    for(int i = 0; i < J_gdzie.size(); i++){
        int ind_j = J_gdzie[i];
        cout << ind_j << " ";
        if(J_gdzie.size() - J[ind_j] + 1 >= k){
            if(O[J_gdzie[i + k - 1]] >= O_gdzie.size()){
                continue;
            }
            int ind_o = O_gdzie[O[J_gdzie[i + k - 1]]];
            cout << ind_o << " ";
            if(O_gdzie.size() - O[ind_o] + 1 >= k){
                int ind_i = I_gdzie[I[O_gdzie[O[J_gdzie[k - 1]] + k - 1]]];
                cout << ind_i << " ";
                if(I_gdzie.size() - I[ind_i] + 1 >= k){
                    cout << "a";
                    wynik = min(wynik, I_gdzie[I[O_gdzie[O[J_gdzie[k - 1]] + k - 1]] + k - 1] - ind_j + 1 - 3 * k);
                }
            }
        }
        cout << endl;
    }
    if(wynik == 200001){
        wynik = -1;
    }
    cout << wynik;
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0; i < J_gdzie.size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~
ho_t2.cpp:40:42: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |         if(J_gdzie.size() - J[ind_j] + 1 >= k){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
ho_t2.cpp:41:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             if(O[J_gdzie[i + k - 1]] >= O_gdzie.size()){
      |                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
ho_t2.cpp:46:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |             if(O_gdzie.size() - O[ind_o] + 1 >= k){
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
ho_t2.cpp:49:50: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |                 if(I_gdzie.size() - I[ind_i] + 1 >= k){
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -