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 + buttons[i]) == n) {
return ans + buttons[i];
}
}
return ans + buttons[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |