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;
for(int i=0;i<3;i++){
t[0]=val[i];
if(press(t)){res[0]=t[0];first=i;break;}
}
if(res[0]=='U'){res[0]='Y';first=3;}
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... |