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 <string>
using namespace std;
char S[3], f;
string guess_sequence(int N) {
string Q = "", Ans = "";
//get first
if (press("AB")) {
if (press("A")) {
f = 'A', S[0] = 'B', S[1] = 'X', S[2] = 'Y';
} else {
f = 'B', S[0] = 'A', S[1] = 'X', S[2] = 'Y';
}
} else {
if (press("X")) {
f = 'X', S[0] = 'B', S[1] = 'A', S[2] = 'Y';
} else {
f = 'Y', S[0] = 'A', S[1] = 'X', S[2] = 'B';
}
}
Ans += f;
//get bulk
for (int i=1; i<=N-2; i++) {
Q = "";
Q += Ans;
Q.push_back(S[0]);
Q.push_back(S[0]);
Q += Ans;
Q.push_back(S[0]);
Q.push_back(S[1]);
Q += Ans;
Q.push_back(S[0]);
Q.push_back(S[2]);
Q += Ans;
Q.push_back(S[1]);
int res = press(Q);
if (res == i) {Ans+=S[2];}
else if (res == i+1) {Ans+=S[1];}
else {Ans+=S[0];}
}
//get last
Q = "";
Q += Ans;
Q.push_back(S[0]);
Q += Ans;
Q.push_back(S[1]);
if (press(Q) == N) {
Q = "";
Q += Ans;
Q.push_back(S[0]);
if (press(Q) == N) {
Ans+=S[0];
} else {
Ans+=S[1];
}
} else {
Ans+=S[2];
}
return(Ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |