Submission #806469

#TimeUsernameProblemLanguageResultExecution timeMemory
806469AlphaMale06Combo (IOI18_combo)C++14
100 / 100
29 ms528 KiB
#include <bits/stdc++.h> #include <combo.h> using namespace std; #define pb push_back char guess_first(){ int ans = press("AB"); if(ans==0){ ans=press("X"); if(ans==1){ return 'X'; } return 'Y'; } else{ ans=press("A"); if(ans==1){ return 'A'; } return 'B'; } } string guess_sequence(int n){ char f = guess_first(); vector<char> nf; if('A'!=f)nf.pb('A'); if('B'!=f)nf.pb('B'); if('X'!=f)nf.pb('X'); if('Y'!=f)nf.pb('Y'); int gsd=1; string ans= ""; ans+=f; if(n==1){ return ans; } while(gsd<n-1){ string gs=ans+nf[0]+nf[0]+ans+nf[0]+nf[1]+ans+nf[0]+nf[2]+ans+nf[1]; int kita=press(gs); if(kita==gsd){ ans+=nf[2]; } else if(kita==gsd+1){ ans+=nf[1]; } else if(kita==gsd+2){ ans+=nf[0]; } gsd++; } string gs=ans+nf[0]; if(press(gs)==n){ return gs; } else{ gs.pop_back(); gs+=nf[1]; if(press(gs)==n){ return gs; } else{ gs.pop_back(); return gs+nf[2]; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...