제출 #209672

#제출 시각아이디문제언어결과실행 시간메모리
209672origami100JJOOII 2 (JOI20_ho_t2)C++11
13 / 100
2095 ms9864 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; string s; cin >> s; set <int> J, O, I; for(int i = 0; i < n; i++){ switch(s[i]){ case 'J': J.insert(i); break; case 'O': O.insert(i); break; case 'I': I.insert(i); break; } } set <int>::iterator it1, it2, it3; it1 = J.begin(); int mi = 200005; bool pos; for(int i = 0; i < J.size() - k + 1; i++){ pos = true; it2 = it1; //cout << *it1 << ' '; for(int j = 0; j < k - 1 && pos; j++){ it2++; if(it2 == J.end()){ pos = false; } } if(pos == false) continue; //cout << *it2 << ' '; it2 = O.upper_bound(*it2); if(it2 == O.end()){ continue; } //cout << *it2 << ' '; for(int j = 0; j < k - 1 && pos; j++){ it2++; if(it2 == O.end()){ pos = false; } } if(pos == false) continue; //cout << *it2 << ' '; it2 = I.upper_bound(*it2); if(it2 == I.end()){ continue; } //cout << *it2 << ' '; for(int j = 0; j < k - 1 && pos; j++){ it2++; if(it2 == I.end()){ pos = false; } } if(pos == false) continue; //cout << *it2 << '\n'; mi = min(mi, *it2 - *it1 + 1 - (k * 3)); it1++; } if(mi == 200005) cout << -1; else cout << mi; }

컴파일 시 표준 에러 (stderr) 메시지

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:26:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < J.size() - k + 1; i++){
                 ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...