Submission #851850

# Submission time Handle Problem Language Result Execution time Memory
851850 2023-09-20T17:14:42 Z LBP139 Karte (COCI15_karte) C++17
50 / 50
1 ms 428 KB
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main(){
    string S;
    cin>>S;
    set<int>P;
    set<int>K;
    set<int>H;
    set<int>T;
    int r=0;
    while(r<S.size()){
        if(S[r]=='P'){
            if(S[r+1]=='0'){
                string a;
                a.push_back(S[r+2]);
                int b=stoi(a);
                if(P.find(b)!=P.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                P.insert(b);
                }
            }
            else{
                string a;
                a.push_back(S[r+1]);
                a.push_back(S[r+2]);
                int b=stoi(a);
                  if(P.find(b)!=P.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                P.insert(b);
                }
            }
        }
        if(S[r]=='K'){
            if(S[r+1]=='0'){
                string g;
                g.push_back(S[r+2]);
                int h=stoi(g);
                if(K.find(h)!=K.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                K.insert(h);
                }
            }
            else{
                string g;
                g.push_back(S[r+1]);
                g.push_back(S[r+2]);
                int h=stoi(g);
                if(K.find(h)!=K.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                K.insert(h);
                }
            }
        }
        if(S[r]=='H'){
            if(S[r+1]=='0'){
                string e;
                e.push_back(S[r+2]);
                int f=stoi(e);
                if(H.find(f)!=H.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                H.insert(f);
                }
            }
            else{
                string e;
                e.push_back(S[r+1]);
                e.push_back(S[r+2]);
                int f=stoi(e);
                     if(H.find(f)!=H.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                H.insert(f);
                }
            }
        }
        if(S[r]=='T'){
            if(S[r+1]=='0'){
                string c;
                c.push_back(S[r+2]);
                int d=stoi(c);
                if(T.find(d)!=T.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                T.insert(d);
                }
            }
            else{
                string c;
                c.push_back(S[r+1]);
                c.push_back(S[r+2]);
                int d=stoi(c);
                   if(T.find(d)!=T.end()){
                    cout<<"GRESKA"<<endl;
                    r=0;
                    break;
                }
                else{
                T.insert(d);
                }
            }
        }
        r=r+3;
    }
    if(r>=S.size()){
        cout<<13-P.size()<<" "<<13-K.size()<<" "<<13-H.size()<<" "<<13-T.size()<<endl;
    }
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:13:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while(r<S.size()){
      |           ~^~~~~~~~~
karte.cpp:132:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  132 |     if(r>=S.size()){
      |        ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 428 KB Output is correct
10 Correct 1 ms 348 KB Output is correct