Submission #75115

#TimeUsernameProblemLanguageResultExecution timeMemory
75115DiuvenCombo (IOI18_combo)C++14
100 / 100
54 ms464 KiB
#include "combo.h" using namespace std; string guess_sequence(int n) { string S="AB", R=""; char Q[5]="ABXY"; if(press(S)!=0){ if(press("A")) R+='A'; else R+='B'; } else{ if(press("X")) R+='X'; else R+='Y'; } if(n==1) return R; for(int i=0; i<4; i++) if(Q[i]==R[0]){ swap(Q[i], Q[3]); break; } for(int i=2; i<=n-1; i++){ S.clear(); for(int j=0; j<3; j++) S += R + Q[0] + Q[j]; S += R + Q[1]; int now=press(S); if(now==i+1) R+=Q[0]; if(now==i) R+=Q[1]; if(now==i-1) R+=Q[2]; } for(int i=0; i<2; i++) if(press(R+Q[i])==n){ R+=Q[i]; break; } if((int)R.size()!=n) R+=Q[2]; return R; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...