| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 207816 | bensonlzl | JJOOII 2 (JOI20_ho_t2) | C++14 | 21 ms | 3944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int N, K, nextJ[200005], nextO[200005], nextI[200005];
vector<int> posJ, posO, posI;
char x[200005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K;
for (int i = 1; i <= N; ++i){
cin >> x[i];
if (x[i] == 'J') posJ.push_back(i);
if (x[i] == 'O') posO.push_back(i);
if (x[i] == 'I') posI.push_back(i);
}
int lastJ = N+1, lastO = N+1, lastI = N+1;
for (int i = N; i >= 1; --i){
nextJ[i] = lastJ;
nextO[i] = lastO;
nextI[i] = lastI;
if (x[i] == 'J') lastJ = i;
if (x[i] == 'O') lastO = i;
if (x[i] == 'I') lastI = i;
}
int mini = 1e9;
for (int i = 0; i < posJ.size() - K + 1; ++i){
int lJ = posJ[i], rJ = posJ[i+K-1];
int lO = nextO[rJ];
auto itO = lower_bound(posO.begin(),posO.end(),lO);
if (itO - posO.begin() > posO.size() - K) break;
int rO = *(itO + K - 1);
int lI = nextI[rO];
auto itI = lower_bound(posI.begin(),posI.end(),lI);
if (itI - posI.begin() > posI.size() - K) break;
int rI = *(itI + K - 1);
mini = min(mini,rI - lJ + 1 - 3 * K);
}
if (mini == 1e9){
cout << -1 << '\n';
}
else cout << mini << '\n';
}컴파일 시 표준 에러 (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... | ||||
