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<string>
#include<vector>
#include "combo.h"
using namespace std;
std::string guess_sequence(int N) {
string t="";
char st;
if(press("AB")){
if(press("A")) t+="A";
else t+="B";
}
else{
if(press("X")) t+="X";
else t+="Y";
}
st=t[0];
vector<string> base(4,"");
string poss="ABXY",tmp="";
for(int i=0;i<4;i++){
if(poss[i]!=st) tmp+=poss[i];
}
poss=tmp;
base[0]+=poss[0];
for(int i=2;i>=0;i--){
base[i]=base[0];
base[i]+=poss[i];
}
base[3]+=poss[1];
for(int i=1;i<N-1;i++){
string guess="";
for(int j=0;j<4;j++){
guess+=t+base[j];
}
//cout<<guess<<"\n";
int res=press(guess);
//cout<<res;
if(res==i+2) t+=poss[0];
else if(res==i+1) t+=poss[1];
else t+=poss[2];
}
if(press(t+poss[0])==N) t+=poss[0];
else if(press(t+poss[1])==N) t+=poss[1];
else t+=poss[2];
return t;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |