#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
std::string guess_sequence(int N) {
string p = "";
int ans = press("AB");
if (ans == 2) {
p = "AB";
} else if (ans == 1) {
p = "A";
} else {
if (press("X") == 1) {
p = "X";
} else {
p = "Y";
}
}
string fix1, fix2, fix3;
if (p[0] == 'A') { fix1 = "X"; fix2 = "B"; fix3 = "Y"; }
if (p[0] == 'B') { fix1 = "A"; fix2 = "X"; fix3 = "Y"; }
if (p[0] == 'X') { fix1 = "A"; fix2 = "B"; fix3 = "Y"; }
if (p[0] == 'Y') { fix1 = "A"; fix2 = "B"; fix3 = "X"; }
while (p.size() < N) {
string pnext = p + fix1 + p + fix2 + fix3 + p + fix2 + fix1 + p + fix2 + fix2;
int res = press(pnext);
int sz = p.size();
if (res == sz) {
p += fix3;
} else if (res == sz + 1) {
p += fix1;
} else {
p += fix2;
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |