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 <bits/stdc++.h>
using namespace std;
int press(string p);
string guess_sequence(int n) {
int in, t;
string out, s, c;
in = press("AB");
if (in) {
in = press("A");
in ? out="A" : out="B";
}
else {
in = press("X");
in ? out="X" : out="Y";
}
string tmp = "ABXY";
for (int i=0; i<4; i++) if (tmp[i]!=out[0]) c+=tmp[i];
for (t=1; t<n-1; t++) {
s = out;
s += c[0];
for (int i=0; i<3; i++) {
s += out;
s += c[1];
s += c[i];
}
in = press(s);
if (in == t) out+=c[2];
else if (in == t+1) out+=c[0];
else if (in == t+2) out+=c[1];
}
if (t==n-1) {
if (n == press(out+c[0])) out+=c[0];
else if (n == press(out+c[1])) out+=c[1];
else out+=c[2];
}
return out;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |