Submission #655907

#TimeUsernameProblemLanguageResultExecution timeMemory
655907PikachudoraEHEJJOOII 2 (JOI20_ho_t2)C++14
0 / 100
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...