# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
851850 | LBP139 | Karte (COCI15_karte) | C++17 | 1 ms | 428 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |