# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
209672 | origami100 | JJOOII 2 (JOI20_ho_t2) | C++11 | 2095 ms | 9864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |