Submission #95636

#TimeUsernameProblemLanguageResultExecution timeMemory
95636jamielimCombo (IOI18_combo)C++14
100 / 100
86 ms560 KiB
#include <bits/stdc++.h> #include "combo.h" std::string guess_sequence(int N){ if(N==1){ if(press("A")==1)return "A"; if(press("B")==1)return "B"; if(press("X")==1)return "X"; return "Y"; } std::string test=""; std::string ans=""; if(press("AB")!=0){ if(press("A")==1){ for(int i=0;i<4*N;i++)test.push_back('A'); ans.push_back('A'); }else{ for(int i=0;i<4*N;i++)test.push_back('B'); ans.push_back('B'); } }else{ if(press("X")==1){ for(int i=0;i<4*N;i++)test.push_back('X'); ans.push_back('X'); }else{ for(int i=0;i<4*N;i++)test.push_back('Y'); ans.push_back('Y'); } } //2 for(int i=1;i<N-1;i++){ //N-2 if(ans[0]=='A'){ test[i]='B';test[i+1]='B'; test[N+i]='B';test[N+i+1]='X'; test[2*N+i]='B';test[2*N+i+1]='Y'; test[3*N+i]='X'; int k=press(test); test[i+1]='A'; test[N+i+1]='A'; test[2*N+i+1]='A'; if(k==i+2){ test[3*N+i]='B'; ans.push_back('B'); }else if(k==i+1){ test[i]='X'; test[N+i]='X'; test[2*N+i]='X'; ans.push_back('X'); }else{ test[i]='Y'; test[N+i]='Y'; test[2*N+i]='Y'; test[3*N+i]='Y'; ans.push_back('Y'); } }else if(ans[0]=='B'){ test[i]='A';test[i+1]='A'; test[N+i]='A';test[N+i+1]='X'; test[2*N+i]='A';test[2*N+i+1]='Y'; test[3*N+i]='X'; int k=press(test); test[i+1]='B'; test[N+i+1]='B'; test[2*N+i+1]='B'; if(k==i+2){ test[3*N+i]='A'; ans.push_back('A'); }else if(k==i+1){ test[i]='X'; test[N+i]='X'; test[2*N+i]='X'; ans.push_back('X'); }else{ test[i]='Y'; test[N+i]='Y'; test[2*N+i]='Y'; test[3*N+i]='Y'; ans.push_back('Y'); } }else if(ans[0]=='X'){ test[i]='A';test[i+1]='A'; test[N+i]='A';test[N+i+1]='B'; test[2*N+i]='A';test[2*N+i+1]='Y'; test[3*N+i]='B'; int k=press(test); test[i+1]='X'; test[N+i+1]='X'; test[2*N+i+1]='X'; if(k==i+2){ test[3*N+i]='A'; ans.push_back('A'); }else if(k==i+1){ test[i]='B'; test[N+i]='B'; test[2*N+i]='B'; ans.push_back('B'); }else{ test[i]='Y'; test[N+i]='Y'; test[2*N+i]='Y'; test[3*N+i]='Y'; ans.push_back('Y'); } }else{ test[i]='A';test[i+1]='A'; test[N+i]='A';test[N+i+1]='B'; test[2*N+i]='A';test[2*N+i+1]='X'; test[3*N+i]='B'; int k=press(test); test[i+1]='Y'; test[N+i+1]='Y'; test[2*N+i+1]='Y'; if(k==i+2){ test[3*N+i]='A'; ans.push_back('A'); }else if(k==i+1){ test[i]='B'; test[N+i]='B'; test[2*N+i]='B'; ans.push_back('B'); }else{ test[i]='X'; test[N+i]='X'; test[2*N+i]='X'; test[3*N+i]='X'; ans.push_back('X'); } } } if(ans[0]=='A'){ ans.push_back('B'); if(press(ans)==N)return ans; ans[N-1]='X'; if(press(ans)==N)return ans; ans[N-1]='Y'; return ans; }else if(ans[0]=='B'){ ans.push_back('A'); if(press(ans)==N)return ans; ans[N-1]='X'; if(press(ans)==N)return ans; ans[N-1]='Y'; return ans; }else if(ans[0]=='X'){ ans.push_back('A'); if(press(ans)==N)return ans; ans[N-1]='B'; if(press(ans)==N)return ans; ans[N-1]='Y'; return ans; }else{ ans.push_back('A'); if(press(ans)==N)return ans; ans[N-1]='B'; if(press(ans)==N)return ans; ans[N-1]='X'; return ans; } //2 return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...