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 <string>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
int r;
string t = "ABXY", p, s = "";
r = press("AB");
if(r == 0) {
r = press("X");
if(r == 0) s = "Y";
else s = "X";
} else {
r = press("A");
if(r == 0) s = "B";
else s = "A";
}
if(N == 1) return s;
for(int i=0; i<4; i++) {
if(t[i] == s[0]) {
t = t.substr(0,i) + (i+1<4 ? t.substr(i+1) : "");
break;
}
}
for(int i=1; i+1<N; i++) {
p = "";
for(int j=0; j<3; j++) {
p += s + t[0] + t[j];
}
p += s + t[1];
r = press(p);
if(r == i) {
s += t[2];
} else if(r == i+1) {
s += t[1];
} else s += t[0];
}
r = press(s + t[0]);
if(r == N) s += t[0];
else {
r = press(s + t[1]);
if(r == N) 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... |