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"
std::string guess_sequence(int N) {
char val[4]={'A','B','X','Y'};
std::string res="U";
std::string t="U";
int first=-1;
t="AB";
if(press(t)){
t="A";
if(press(t)){
res[0]='A';
first=0;
}
else{
res[0]='B';
first=1;
}
}
else{
t="X";
if(press(t)){
res[0]='X';
first=2;
}
else{
res[0]='Y';
first=3;
}
}
if(N==1)return res;
for(int i=1;i<N-1;i++){
t=res;
for(int j=1;j<=3;j++)
{t+=val[(first+1)%4];t+=val[(first+j)%4];t+=res;}
t+=val[(first+2)%4];
int g=press(t);
if(g==i+2)
res+=val[(first+1)%4];
else if(g==i+1)
res+=val[(first+2)%4];
else
res+=val[(first+3)%4];
}
if(press(res+val[(first+1)%4])==N)
res+=val[(first+1)%4];
else if(press(res+val[(first+2)%4])==N)
res+=val[(first+2)%4];
else
res+=val[(first+3)%4];
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |