# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
881753 | AlphaMale06 | JJOOII 2 (JOI20_ho_t2) | C++14 | 10 ms | 4832 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
string s;
cin >> s;
int L, R;
vector<int> posj, poso, posi;
int pos[n];
for(int i=0; i< n; i++){
if(s[i]=='J'){
posj.pb(i);
pos[i]=posj.size()-1;
}
else if(s[i]=='O'){
poso.pb(i);
pos[i]=poso.size()-1;
}
else{
posi.pb(i);
pos[i]=posi.size()-1;
}
}
int szj, szo, szi;
szj=posj.size(); szo=poso.size(); szi=posi.size();
int ans=1e9;
for(int i=0; i+k<=szj; i++){
int ind=posj[i+k-1];
auto its=upper_bound(poso.begin(), poso.end(), ind);
if(its==poso.end())break;
int ind2=*its;
ind2=pos[ind2];
ind2+=k-1;
if(ind2>=szo)break;
its=upper_bound(posi.begin(), posi.end(), poso[ind2]);
if(its==posi.end())break;
int ind3=*its;
ind3=pos[ind3];
ind3+=k-1;
if(ind3>=szi)break;
ans=min(ans, posi[ind3]-posj[i]-3*k+1);
}
if(ans>1e8)cout << -1 << '\n';
else cout << ans << '\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... |