Submission #1110890

#TimeUsernameProblemLanguageResultExecution timeMemory
1110890HasanV11010238Combo (IOI18_combo)C++17
100 / 100
50 ms2108 KiB
#include "combo.h" #include <vector> using namespace std; vector<char> c = {'A', 'B', 'X', 'Y'}; string guess_sequence(int N){ string ans = "", q; int l = 0, r = 3; while (l != r){ int mid = (l + r) / 2; q = ""; for (int i = l; i <= mid; i++){ q += c[i]; } if (press(q) == 0){ l = mid + 1; } else{ r = mid; } } vector<char> al; for (int i = 0; i < 4; i++){ if (l != i){ al.push_back(c[i]); } } ans += c[l]; if (N == 1) return ans; for (int i = 0; i < N - 2; i++){ q = ans + al[0] + ans + al[1] + al[0] + ans + al[1] + al[1] + ans + al[1] + al[2]; int res = press(q); if (res == i + 1){ ans += al[2]; } else if (res == i + 2){ ans += al[0]; } else{ ans += al[1]; } } if (press(ans + al[0]) == N) return ans + al[0]; if (press(ans + al[1]) == N) return ans + al[1]; return ans + al[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...