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"
using namespace std;
string guess_sequence(int N) {
string S;
if (press("AB")) {
if (press("A"))
S += 'A';
else
S += 'B';
} else {
if (press("X"))
S += 'X';
else
S += 'Y';
}
string t = "ABXY";
t.erase(t.find(S[0]), 1);
for (int i = 1; i < N - 1; i++) {
string p = "";
p += S + t[0];
p += S + t[1] + t[0];
p += S + t[1] + t[1];
p += S + t[1] + t[2];
int x = press(p) - (int)S.size();
if (x == 0) S += t[2];
if (x == 1) S += t[0];
if (x == 2) S += t[1];
}
if ((int)S.size() < N) {
if (press(S + t[0] + S + t[1]) == N) {
if (press(S + t[0]) == N)
S += t[0];
else S += t[1];
} else {
S += t[2];
}
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |