Submission #631680

#TimeUsernameProblemLanguageResultExecution timeMemory
631680StavabCombo (IOI18_combo)C++14
100 / 100
47 ms472 KiB
#include <combo.h> using namespace std; string guess_sequence(int N) { string s; char c[3]; if(press("XY")) { if(press("X")) { s.push_back('X'); c[0] = 'Y'; c[1] = 'A'; c[2] = 'B'; } else { s.push_back('Y'); c[0] = 'X'; c[1] = 'A'; c[2] = 'B'; } } else { if(press("A")) { s.push_back('A'); c[0] = 'X'; c[1] = 'Y'; c[2] = 'B'; } else { s.push_back('B'); c[0] = 'X'; c[1] = 'A'; c[2] = 'Y'; } } string newS; for(int i = 2; i < N; i++) { newS = ""; s.push_back(c[0]); for(int j = 0; j < 3; j++) { s.push_back(c[j]); newS += s; s.pop_back(); } s.pop_back(); s.push_back(c[1]); newS += s; s.pop_back(); int ans = press(newS); if(ans == i + 1) s.push_back(c[0]); else if(ans == i) s.push_back(c[1]); else s.push_back(c[2]); } if(N != 1) { s.push_back(c[0]); if(press(s) != N) { s.pop_back(); s.push_back(c[1]); if(press(s) != N) { s.pop_back(); s.push_back(c[2]); } } } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...