# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413584 | timmyfeng | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"
string guess_sequence(int n) {
string ans;
if (press("AB") > 0) {
ans = press("A") > 0 ? "A" : "B";
} else {
ans = press("X") > 0 ? "X" : "Y";
}
string buttons = "ABXY";
buttons.erase(find(buttons.begin(), buttons.end(), ans[0]));
for (int i = 1; i < n - 1; ++i) {
string ask = ans + buttons[1];
for (int j = 0; j < 3; ++j) {
ask += ans + buttons[2] + buttons[j];
}
int res = press(ask);
for (int j = 0; j < 3; ++j) {
if (res == i + j) {
ans += buttons[j];
}
}
}
for (int i = 0; i < 2; ++i) {
if (press(ans + button[i]) == n) {
return ans + button[i];
}
}
return ans + button[2];
}