Submission #309694

#TimeUsernameProblemLanguageResultExecution timeMemory
309694keta_tsimakuridzeCombo (IOI18_combo)C++14
100 / 100
37 ms556 KiB
#include "combo.h" std::string guess_sequence(int N) { std::string p ="AB"; std:: string ans=""; int coins = press(p); if(coins && press("A")) ans+='A'; else if(coins) ans+="B"; else if(press("X")) ans+="X"; else ans+="Y"; for (int i = 1; i < N-1; ++i) { std:: string S=""; S+=ans; if(ans[0]=='A'){ S+='B'; S+=ans; S+="XY"; S+=ans; S+="XB"; S+=ans; S+="XX"; coins=press(S); if(coins==i+1) ans+='B'; else if(coins==i+2) ans+='X'; else ans+='Y'; } else if(ans[0]=='B'){ S+='A'; S+=ans; S+="XY"; S+=ans; S+="XA"; S+=ans; S+="XX"; coins=press(S); if(coins==i+1) ans+='A'; else if(coins==i+2) ans+='X'; else ans+='Y'; } else if(ans[0]=='X'){ S+='B'; S+=ans; S+="AY"; S+=ans; S+="AB"; S+=ans; S+="AA"; coins=press(S); if(coins==i+1) ans+='B'; else if(coins==i+2) ans+='A'; else ans+='Y'; } else{ S+='B'; S+=ans; S+="AA"; S+=ans; S+="AB"; S+=ans; S+="AX"; coins=press(S); if(coins==i+1) ans+='B'; else if(coins==i+2) ans+='A'; else ans+='X'; } // std::cout<<ans[i]<<" "; } if(N!=1){ if(ans[0]=='X'){ if(press(ans+'Y')==N) ans+='Y'; else if(press(ans+'A')==N)ans+='A'; else ans+='B'; } else if(ans[0]=='Y'){ if(press(ans+'X')==N) ans+='X'; else if(press(ans+'A')==N)ans+='A'; else ans+='B'; } else if(ans[0]=='A'){ if(press(ans+'X')==N) ans+='X'; else if(press(ans+'Y')==N)ans+='Y'; else ans+='B'; } else{ if(press(ans+'X')==N) ans+='X'; else if(press(ans+'A')==N)ans+='A'; else ans+='Y'; }} return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...