Submission #153866

# Submission time Handle Problem Language Result Execution time Memory
153866 2019-09-17T05:49:29 Z nicolaalexandra Karte (COCI15_karte) C++14
50 / 50
2 ms 376 KB
#include <iostream>
#include <cstring>
using namespace std;
int f[5][20],sol[5];
char s[1010];
int n,i,j;
int main (){

    cin>>s+1;
    n = strlen (s+1);
    for (i=1;i<=n;i+=3){
        int nr = (s[i+1]-'0')*10+s[i+2]-'0';
        if (s[i] == 'P')
            f[0][nr]++;
        if (s[i] == 'K')
            f[1][nr]++;
        if (s[i] == 'H')
            f[2][nr]++;
        if (s[i] == 'T')
            f[3][nr]++;
    }
    for (i=0;i<=3;i++){
        int nr = 0;
        for (j=1;j<=13;j++){
            if (f[i][j] > 1){
                cout<<"GRESKA";
                return 0;
            }
            nr += f[i][j];
        }
        sol[i] = 13-nr;
    }
    cout<<sol[0]<<" "<<sol[1]<<" "<<sol[2]<<" "<<sol[3];
    return 0;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:9:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     cin>>s+1;
          ~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct