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;
string guess_sequence(int N) {
string p;
if (press("AB")) {
p = press("A") ? "A" : "B";
} else {
p = press("X") ? "X" : "Y";
}
if (N == 1) return p;
vector<char> opts{'A', 'B', 'X', 'Y'};
opts.erase(find(opts.begin(), opts.end(), p[0]));
for (int i = 1; i < N - 1; ++i) {
string k;
k += p + opts[0] + opts[0];
k += p + opts[0] + opts[1];
k += p + opts[0] + opts[2];
k += p + opts[1];
int c = press(k);
if (c == i + 2) {
p += opts[0];
} else if (c == i + 1) {
p += opts[1];
} else {
p += opts[2];
}
}
for (int j = 0; j < 2; ++j) {
if (press(p + opts[j]) == N) {
return p + opts[j];
}
}
return p + opts[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |