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 "grader.cpp"
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
string ans;
char ch[5]={'A','B','X','Y'};
char lft[5];
string guess_sequence(int n)
{
int pref;
char st;
for(int i=1;i<=n;i++)
{
string ask = "";
if(i==1)
{
ask+='A',ask+='B';
pref = press(ask);
if(pref)
{
ask.clear();
ask+='A';
pref = press(ask);
if(pref) st = 'A';
else st = 'B';
}
else
{
ask.clear();
ask+='X';
pref = press(ask);
if(pref) st = 'X';
else st = 'Y';
}
int cnt = 0;
for(int i=0;i<4;i++)
if(ch[i]!=st) lft[cnt++] = ch[i];
ans+=st;
}
else if(i!=n)
{
ask+=ans,ask+=lft[0];
ask+=ans,ask+=lft[1],ask+=lft[0];
ask+=ans,ask+=lft[1],ask+=lft[1];
ask+=ans,ask+=lft[1],ask+=lft[2];
pref = press(ask);
if(pref==i+1) ans+=lft[1];
else if(pref==i) ans+=lft[0];
else ans+=lft[2];
}
else
{
ask+=ans;
ask+=lft[0];
pref = press(ask);
if(pref==n) ans+=lft[0];
else
{
ask.clear();
ask+=ans;
ask+=lft[1];
pref = press(ask);
if(pref==n) ans+=lft[1];
else ans+=lft[2];
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |