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>
std::string guess_sequence(int N) {
std::string p = "";
std::string S = "";
std::string a, b, c;
if (N == 1) {
if (press("A") == 1) return "A";
if (press("B") == 1) return "B";
if (press("X") == 1) return "X";
return "Y";
}
p = "AB";
int res = press(p);
if (res > 0) {
p = "AXAYAAAB";
res = press(p);
if (res == 2) {
S = "A";
a = "B"; b = "X", c = "Y";
} else {
S = "B";
a = "A"; b = "X", c = "Y";
}
} else {
p = "XAXBXXXY";
res = press(p);
if (res == 2) {
S = "X";
a = "B"; b = "A", c = "Y";
} else {
S = "Y";
a = "B"; b = "X", c = "A";
}
}
for (int i = 1; i < N - 1; ++i) {
p = S + a + a + S + a + b + S + a + c + S + b;
res = press(p);
if (res == i + 2) S += a;
if (res == i + 1) S += b;
if (res == i) S += c;
}
p = S + a;
if (press(p) == N) return p;
p = S + b;
if (press(p) == N) return p;
return S + c;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |