# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
401550 | tredsused70 | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
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;
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";
}
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();
}
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;
}