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="AB", R="";
char Q[5]="ABXY";
if(press(S)!=0){
if(press("A")) R+='A';
else R+='B';
}
else{
if(press("X")) R+='X';
else R+='Y';
}
if(n==1) return R;
for(int i=0; i<4; i++) if(Q[i]==R[0]){
swap(Q[i], Q[3]); break;
}
for(int i=2; i<=n-1; i++){
S.clear();
for(int j=0; j<3; j++)
S += R + Q[0] + Q[j];
S += R + Q[1];
int now=press(S);
if(now==i+1) R+=Q[0];
if(now==i) R+=Q[1];
if(now==i-1) R+=Q[2];
}
for(int i=0; i<2; i++) if(press(R+Q[i])==n){
R+=Q[i]; break;
}
if((int)R.size()!=n) R+=Q[2];
return R;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |