Submission #1115757

#TimeUsernameProblemLanguageResultExecution timeMemory
1115757staszic_ojuzJJOOII 2 (JOI20_ho_t2)C++17
0 / 100
1 ms336 KiB
#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]; 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]]]; if(O_gdzie.size() - O[ind_o] + 1 >= k){ int ind_i = I_gdzie[I[O_gdzie[O[J_gdzie[k - 1]] + k - 1]]]; if(I_gdzie.size() - I[ind_i] + 1 >= k){ wynik = min(wynik, I_gdzie[I[O_gdzie[O[J_gdzie[k - 1]] + k - 1]] + k - 1] - ind_j + 1 - 3 * k); } } } } if(wynik == 200001){ wynik = -1; } cout << wynik; }

Compilation message (stderr)

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:39:42: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if(J_gdzie.size() - J[ind_j] + 1 >= k){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
ho_t2.cpp:40:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             if(O[J_gdzie[i + k - 1]] >= O_gdzie.size()){
      |                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
ho_t2.cpp:44:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |             if(O_gdzie.size() - O[ind_o] + 1 >= k){
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
ho_t2.cpp:46:50: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |                 if(I_gdzie.size() - I[ind_i] + 1 >= k){
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...