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"
char c[4]={'A','B','X','Y'};
int st;
std::string guess_sequence(int N) {
std::string s = "";
int temp;
temp=press("AB");
if(temp)
{
if(press("A")) {s+="A"; st=0;}
else {s+="B"; st=1;}
}
else
{
if(press("X")) {s+="X"; st=2;}
else {s+="Y"; st=3;}
}
if(N==1) return s;
std:: string test="";
for(int i=1;i<N-1;i++)
{
test.clear();
test+=s;
test.push_back(c[(st+1)%4]);
test.push_back(c[(st+1)%4]);
test+=s;
test.push_back(c[(st+1)%4]);
test.push_back(c[(st+2)%4]);
test+=s;
test.push_back(c[(st+1)%4]);
test.push_back(c[(st+3)%4]);
test+=s;
test.push_back(c[(st+2)%4]);
temp=press(test)-i;
if(temp==2) s.push_back(c[(st+1)%4]);
else if(temp==1) s.push_back(c[(st+2)%4]);
else s.push_back(c[(st+3)%4]);
}
for(int i=1;i<=2;i++)
{
s.push_back(c[(st+i)%4]);
if(press(s)==N) return s;
s.pop_back();
}
s.push_back(c[(st+3)%4]);
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |