This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define all(x) x.begin(),x.end();
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,k;
cin>>n>>k;
string str;
cin>>str;
char cur='J';
int cnt=0;
bool tf=false;
int ans=0;
for(int i=0;i<n;i++){
if(str[i]!=cur){
if(tf) ans++;
continue;
}
if(cur=='J' and cnt==0){
tf=true;
}
cnt++;
if(cnt==k){
if(cur=='I'){
cout<<ans;
return 0;
}
else{
if(cur=='J') cur='O';
else cur='I';
}
cnt=0;
}
}
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... |