Submission #154248

# Submission time Handle Problem Language Result Execution time Memory
154248 2019-09-19T14:29:54 Z Radugnn Karte (COCI15_karte) C++14
50 / 50
3 ms 380 KB
#include <iostream>
#include <string.h>
using namespace std;
char s[1010];
int a[5][20],dim,i;
int main(){
    cin>>s;
    dim=strlen(s);
    for(i=0;i<dim;i++){
        if(s[i]=='P'){
                a[1][0]++;
            if(s[i+1]==0){
                if(a[1][s[i+2]-'0']==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[1][s[i+2]-'0']=1;
                i+=2;
            }
            else{
                if(a[1][(s[i+1]-'0')*10+(s[i+2]-'0')]==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[1][(s[i+1]-'0')*10+(s[i+2]-'0')]=1;
                i+=2;
            }
        }
        else
            if(s[i]=='K'){
                    a[2][0]++;
                if(s[i+1]==0){
                if(a[2][s[i+2]-'0']==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[2][s[i+2]-'0']=1;
                i+=2;
            }
            else{
                if(a[2][(s[i+1]-'0')*10+(s[i+2]-'0')]==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[2][(s[i+1]-'0')*10+(s[i+2]-'0')]=1;
                i+=2;
            }

            }
            else
                if(s[i]=='H'){
                        a[3][0]++;
                if(s[i+1]==0){
                if(a[3][s[i+2]-'0']==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[3][s[i+2]-'0']=1;
                i+=2;
            }
            else{
                if(a[3][(s[i+1]-'0')*10+(s[i+2]-'0')]==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[3][(s[i+1]-'0')*10+(s[i+2]-'0')]=1;
                i+=2;
            }

                }
                else
                    if(s[i]=='T'){
                        a[4][0]++;
                        if(s[i+1]==0){
                if(a[4][s[i+2]-'0']==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[4][s[i+2]-'0']=1;
                i+=2;
            }
            else{
                if(a[4][(s[i+1]-'0')*10+(s[i+2]-'0')]==1){
                    cout<<"GRESKA";
                    return 0;
                }
                a[4][(s[i+1]-'0')*10+(s[i+2]-'0')]=1;
                i+=2;
            }

                    }
    }
    for(i=1;i<=4;i++)
        cout<<13-a[i][0]<<" ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 360 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct