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 <iostream>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
char first = 'A';
string parse(string s) {
for (char &c : s)
if (c == 'A') c = first;
else if (c == first) c = 'A';
return s;
}
int ask(const string &p) { return press(parse(p)); }
string guess_sequence(int n) {
if (ask("AB"))
first = ask("A") ? 'A' : 'B';
else
first = ask("X") ? 'X' : 'Y';
string cur{'A'};
if (n > 1) {
rep(i, 1, n - 1) {
int cnt = ask(cur + "BB" + cur + "BX" + cur + "BY" + cur + "X");
if (cnt == i + 0) cur += "Y";
if (cnt == i + 1) cur += "X";
if (cnt == i + 2) cur += "B";
}
if (ask(cur + "B" + cur + "X") == n)
cur += ask(cur + "B") == n ? "B" : "X";
else cur += "Y";
}
return parse(cur);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |