# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
781517 | vjudge1 | JJOOII 2 (JOI20_ho_t2) | C++17 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N
int main(){
int n,k;cin>>n>>k;
string str;cin>>str;
int ans=1000000000;
for(int i=0;i<n;i++){
int j=0,o=0,I=0;
int cur=0;
int son,ner,de;
for(int jj=i;jj<n;jj++){
//cout<<i<<" "<<jj<<" "<<j<<" "<<o<<" "<<I<<" "<<cur<<" "<<str[jj]<<endl;
if(str[jj]=='J'){
if(j==k)continue;
if(j==0){
son=jj;
j++;
}
else{
cur+=jj-son-1;
son=jj;
j++;
}
}
if(str[jj]=='O'){
if(j!=k)continue;
if(o==k)continue;
if(o==0){
ner=jj;
cur+=ner-son-1;
o++;
}
else{
cur+=jj-ner-1;
ner=jj;
o++;
}
}
if(str[jj]=='I'){
if(j!=k||o!=k)continue;
if(I==0){
de=jj;
cur+=de-ner-1;I++;
}
else{
cur+=jj-de-1;
de=jj;
I++;
if(I==k){
ans=min(ans,cur);break;
}
}
}
}
}
if(ans==1000000000)ans=-1;
cout<<ans<<endl;
}
컴파일 시 표준 에러 (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... |