Submission #445372

#TimeUsernameProblemLanguageResultExecution timeMemory
445372silverfishCombo (IOI18_combo)C++14
0 / 100
28 ms444 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define pb push_back string guess_sequence(int n) { srand(time(0)); string ans=""; vector<char> c, cc = {'A', 'B', 'X', 'Y'}; bool found = 0; for(int i = 0; i < 3; ++i){ if(press(ans+cc[i])){ ans.pb(cc[i]); for(char cch : cc) if(cch != cc[i]) c.pb(cch); found = 1; break; } } if(!found){ ans.pb(cc[3]); for(char cch : cc) if(cch != cc[3]) c.pb(cch); } for(int i = 1; i < n; ++i){ random_shuffle(c.begin(), c.end()); if(i == n-1){ int ret = press(ans+c[0]); if(ret == i+1){ ans.pb(c[0]); }else{ ret = press(ans+c[1]); if(ret == i+1){ ans.pb(c[1]); }else ans.pb(c[2]); } break; } string ask1={c[0],c[0]}, ask2 = {c[0], c[1]}; int ret = press(ans+ask1+ans+ask2); if(ret == i+2){ ret = press(ans+ask1); if(ret == i+2) ans += ask1; else ans += ask2; ++i; }else if(ret == i+1){ ans.pb(c[0]); ans.pb(c[2]); ++i; }else{ ask1 = {c[1], c[0]}, ask2 = {c[1], c[1]}; if(ret == i+2){ ret = press(ans+ask1); if(ret == i+2) ans += ask1; else ans += ask2; ++i; }else if(ret == i+1){ ans.pb(c[1]); ans.pb(c[2]); ++i; }else{ ans.pb(c[2]); } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...