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 <bits/stdc++.h>
using namespace std;
int press(string p);
string guess_sequence(int n)
{
string ans,help;
char st;
if(press("AX"))
{
if(press("A")==1)
ans="A";
else
ans="X";
}
else
{
if(press("B")==1)
ans="B";
else
ans="Y";
}
if(n==1)
return ans;
st=ans[0];
int t;
for(int i=1;i<n-1;i++)
{
if(st=='A')
{
help=ans+"BB"+ans+"BY"+ans+"BX"+ans+"Y";
t=press(help);
if(t==i+2)
ans+="B";
if(t==i+1)
ans+="Y";
if(t==i)
ans+="X";
}
if(st=='B')
{
help=ans+"AA"+ans+"AY"+ans+"AX"+ans+"Y";
t=press(help);
if(t==i+2)
ans+="A";
if(t==i+1)
ans+="Y";
if(t==i)
ans+="X";
}
if(st=='Y')
{
help=ans+"AA"+ans+"AB"+ans+"AX"+ans+"B";
t=press(help);
if(t==i+2)
ans+="A";
if(t==i+1)
ans+="B";
if(t==i)
ans+="X";
}
if(st=='X')
{
help=ans+"AA"+ans+"AB"+ans+"AY"+ans+"B";
t=press(help);
if(t==i+2)
ans+="A";
if(t==i+1)
ans+="B";
if(t==i)
ans+="Y";
}
help.clear();
t=0;
}
help=ans+"B"+ans+"A";
if(press(help)==n)
{
if(press(ans+"B")==n)
ans+="B";
else
ans+="A";
}
else
{
if(press(ans+"X")==n)
ans+="X";
else
ans+="Y";
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |