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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
vector<char> ca {'A', 'B', 'X', 'Y'}, cand;
string guess_sequence (int n) {
string ans;
if (press("AB")) {
if (press("A")) {
ans = "A";
}
else {
ans = "B";
}
}
else {
if (press("X")) {
ans = "X";
}
else {
ans = "Y";
}
}
ca.erase(find(ca.begin(), ca.end(), ans[0]));
for (int i = 1; i < n - 1; ++i) {
string ask = ans + ca[0] + ans + ca[1] + ca[0] + ans + ca[1] + ca[1] + ans + ca[1] + ca[2];
int x = press(ask);
if (x == i) {
ans += ca[2];
}
else if (x == i + 1) {
ans += ca[0];
}
else {
ans += ca[1];
}
}
return n == 1 ? ans : ans + (press(ans + ca[0]) == n ? ca[0] : press(ans + ca[1]) == n ? ca[1] : ca[2]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |