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>
#include <combo.h>
using namespace std;
string guess_sequence(int n) {
string ans = "";
int cnt = press("AB");
if (cnt == 2)
ans = "A";
else if (cnt == 1) ans = (press("A") == 1 ? "A" : "B");
else if (cnt == 0) ans = (press("X") == 1 ? "X" : "Y");
string query = "ABXY";
for (int i = 0; i < 4; ++i) if (query[i] == ans[0]) {
query.erase(i, 1);
break;
}
for (int i = 1; i < n - 1; ++i) {
int id = press(ans + query[2] + query[0] + ans + query[2] + query[1] + ans + query[2] + query[2] + ans + query[1]);
ans += query[id - ans.size()];
}
if (press(ans + query[0]) == n) return ans + query[0];
if (press(ans + query[1]) == n) return ans + query[1];
return ans + query[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |