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>
std::string guess_sequence(int n) {
std::string c = "ABXY", cands, s;
if (!press("AB")) {
s = press("X") ? "X" : "Y";
} else {
s = press("A") ? "A" : "B";
}
if (n == 1) {
return s;
}
for (int i = 0; i < 4; ++i) {
if (c[i] != s[0]) {
cands += c[i];
}
}
for (int i = 1; i + 1 < n; ++i) {
auto msg = s + cands[1] + s + cands[2] + cands[0] + s + cands[2] + cands[1] + s + cands[2] + cands[2];
int ind = press(msg) - s.size();
s += cands[ind];
}
if (press(s + cands[1]) == n) {
return s + cands[1];
}
return press(s + cands[0]) == n ? s + cands[0] : s + cands[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |