답안 #165827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165827 2019-11-29T09:17:23 Z itiam Karte (COCI15_karte) C++11
50 / 50
4 ms 504 KB
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int L[6],Lp[15],Lk[15],Lh[15],Lt[15];   //P=0,K=1,H=2,T=3
int main(){
    int br1,br2,tr=0;
    char S;
    string A;
    cin >> A;
    for (int i=0;i<A.length();i+=3){
        S=(char)A[i];
        br1=(int)A[i+1]-48;
        br2=(int)A[i+2]-48;
        if (S=='P'){
            if (Lp[((br1*10)+br2)]==1){
                tr=1;
                cout << "GRESKA";
                break;
            }
            else    Lp[((br1*10)+br2)]=1;
            L[0]+=1;
        }
        else if (S=='K'){
            if (Lk[((br1*10)+br2)]==1){
                tr=1;
                cout << "GRESKA";
                break;
            }
            else    Lk[((br1*10)+br2)]=1;
            L[1]+=1;
        }
        else if (S=='H'){
            if (Lh[((br1*10)+br2)]==1){
                tr=1;
                cout << "GRESKA";
                break;
            }
            else    Lh[((br1*10)+br2)]=1;
            L[2]+=1;
        }
        else{
            if (Lt[((br1*10)+br2)]==1){
                tr=1;
                cout << "GRESKA";
                break;
            }
            else    Lt[((br1*10)+br2)]=1;
            L[3]+=1;
        }
    }
    if (tr==0){
        for (int i=0;i<4;i++)   cout << 13-L[i] << " ";
    }
    return 0;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:14:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<A.length();i+=3){
                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 4 ms 504 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 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct