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;
std::string guess_sequence(int N) {
std::string p = "";
string s;
string s1;
string s2;
string s3;
int t=press("AB");
if(t!=0){
int t2=press("A");
if(t2==1){
s="A";
s1="B";
s2="X";
s3="Y";
}
else{
s="B";
s1="A";
s2="X";
s3="Y";
}
}
else
{
int t2=press("X");
if(t2==1){
s="X";
s1="B";
s2="Y";
s3="A";
}
else{
s="Y";
s1="B";
s2="X";
s3="A";
}
}
// cout<<"first letter is "<<s<<endl;
int cou=1;
string ans;
ans=s;
for(int i=1;i<N-1;i++){
// cout<<ans<<" "<<ans.size()<<endl;
string f;
f=ans + s1 + ans + s2 + s1 + ans + s2 + s2 + ans + s2 + s3;
int t=press(f);
// cout<<f<<" "<<t<<" "<<f.size()<<"/"<<N<<endl;
// cout<<endl;
if(t==cou+1){
cou++;
ans=ans+s1;
}
else
if(t==cou+2){
cou++;
ans=ans + s2;
}
else
{
cou++;
ans=ans + s3;
}
}
// cout<<"answeeer "<<ans<<endl;
if(press(ans + s1)==N){
ans = ans + s1;
}
else
if(press(ans + s2)==N){
ans = ans + s2;
}
else
ans = ans + s3;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |