Submission #655908

# Submission time Handle Problem Language Result Execution time Memory
655908 2022-11-06T03:29:42 Z PikachudoraEHE JJOOII 2 (JOI20_ho_t2) C++14
0 / 100
1 ms 596 KB
#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;
    char a[300000];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
1 Correct 0 ms 596 KB Output is correct
2 Incorrect 1 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Incorrect 1 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Incorrect 1 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -