Submission #713112

#TimeUsernameProblemLanguageResultExecution timeMemory
713112tht2005Combo (IOI18_combo)C++17
100 / 100
62 ms616 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string tmp[100]; int solve(int l, int r) { if(l == r) { return l; } int m = (l + r) >> 1; string combo; for(int i = m + 1; i <= r; ++i) { for(char ch : tmp[i]) { combo.push_back(ch); } } if(press(combo) >= (int)tmp[0].size()) { return solve(m + 1, r); } return solve(l, m); } string guess_sequence(int N) { string BUTTONS = "ABXY"; for(int i = 0; i < 4; ++i) { tmp[i] = BUTTONS[i]; } int first_button = solve(0, 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...