Submission #713115

#TimeUsernameProblemLanguageResultExecution timeMemory
713115tht2005Combo (IOI18_combo)C++17
100 / 100
65 ms580 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string BUTTONS = "ABXY"; int first_button = press("AB") ? (press("A") ? 0 : 1) : (press("X") ? 2 : 3); swap(BUTTONS[3], BUTTONS[first_button]); string res(1, BUTTONS[3]); for(int i = 2; i < N; ++i) { string ask = res; ask.push_back(BUTTONS[0]); for(int j = 0; j < 3; ++j) { for(char ch : res) { ask.push_back(ch); } ask.push_back(BUTTONS[1]); ask.push_back(BUTTONS[j]); } int o = press(ask); if(o == i) { res.push_back(BUTTONS[0]); } else if(o == i + 1) { res.push_back(BUTTONS[1]); } else { res.push_back(BUTTONS[2]); } } if(N > 1) { int last = 0; for(int ch = 1; ch < 3; ++ch) { string ask = res; ask.push_back(BUTTONS[ch]); if(press(ask) == N) { last = ch; break; } } res.push_back(BUTTONS[last]); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...