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 base = "ABXY";
string guess_sequence(int N) {
string S;
if(press("AB") == 0) {
S = (press("X") == 0) ? "Y" : "X";
}
else {
S = (press("A") == 0) ? "B" : "A";
}
if(N == 1) {
return S;
}
string ord = S;
for(char c:base) {
if(c != S[0]) {
ord.push_back(c);
}
}
for(int i=1;i<N-1;i++) {
string k;
k = k + S + ord.substr(1,1) + ord.substr(1,1);
k = k + S + ord.substr(1,1) + ord.substr(2,1);
k = k + S + ord.substr(1,1) + ord.substr(3,1);
k = k + S + ord.substr(2,1);
int fr = press(k);
if(fr == i) S.push_back(ord[3]);
else if(fr == i+1) S.push_back(ord[2]);
else S.push_back(ord[1]);
}
if(press(S + ord.substr(1,1)) == N) {
S = S + ord.substr(1,1);
}
else {
S = (press(S + ord.substr(2,1)) == N) ? S + ord.substr(2,1) : S + ord.substr(3,1);
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |