제출 #229221

#제출 시각아이디문제언어결과실행 시간메모리
229221monus1042콤보 (IOI18_combo)C++17
100 / 100
40 ms624 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string S=""; if (N==1){ string tot="ABX"; for (int i=0; i<3; i++){ string x; x+=tot[i]; int c=press(x); if (c==1){ return x; } } return "Y"; } string aux="ABX"; int c=press(aux); if (!c){ S+="Y"; }else if (N>=3 && c==3){ S+="A"; }else if (c==2){ int p1=press("AB"); if (p1==2){ S+="A"; }else{ S+="B"; } }else if (c==1){ int p1=press("BYBA"); if (!p1){ S+="X"; }else if (p1==2){ S+="B"; }else S+="A"; } string total="ABXY"; string usingthis=""; for (int i=0; i<4; i++){ if (S[0]==total[i]) continue; usingthis.push_back(total[i]); //cout<<total[i]; } //cout<<endl; int matches=1; for (int i=2; i<=N-1; i++){ string send=S, s1, s2, s3, s4; s1=s2=s3=s4=""; s1+=usingthis[0]; s2+=usingthis[1]; s2+=usingthis[0]; s3+=usingthis[1]; s3+=usingthis[1]; s4+=usingthis[1]; s4+=usingthis[2]; send = send + s1 + S + s2 + S + s3 + S + s4; //cout<<send<<endl; // ch int p1=press(send); //cout<<p1<<endl; if (p1 == matches){ S+=usingthis[2]; }else if (p1 == matches + 2){ S+=s4; S.pop_back(); }else{ S+=s1; } matches++; } //special case i==N: string send=S; send+=usingthis[0]; send+=S; send+=usingthis[1]; int p1=press(send); if (p1 == matches){ S+=usingthis[2]; }else{ string la=S + usingthis[0]; int p2=press(la); if (p2 == matches + 1){ S+=usingthis[0]; }else{ S+=usingthis[1]; } } //cout<<S<<endl; //cout<<N<<'\n'; return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...