이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
char s[]={'J','O','I','Z'};
char *c = s;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,m;cin>>n>>m;int p = 0;int chk = 0;
string a;cin>>a;int cnt = 0;int ch=0;
for(int i=0;i<=n;i++){
//cout<<"O";
if(a[i]==*c&&chk==0){
cnt++;chk=1;
if(cnt%m==0){
c++;
}
//cout<<"1";
}
else if(*c=='Z'){
ch = 1;
//cout<<"final";
break;
}
else if(a[i]==*c){
cnt++;
if(cnt%m==0){
c++;
}
//cout<<c;
}
else if(chk){
p++;
//cout<<"3";
}
}
if(ch){
cout<<p;
}
else{
cout<<"-1";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |