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"
#include<bits/stdc++.h>
using namespace std;
string guess_sequence(int N)
{
string s;
string p;p+='A';p+='B';
if(press(p)>0)
{
string pp;pp+='A';
if(press(pp)>0)s+='A';
else s+='B';
}
else
{
string pp;pp+='X';
if(press(pp)>0)s+='X';
else s+='Y';
}
char a, b, c;
if(s[0]=='A')a='B',b='X',c='Y';
else if(s[0]=='B')a='A',b='X',c='Y';
else if(s[0]=='X')a='A',b='B',c='Y';
else a='A',b='B',c='X';
for(int i=1;i<N-1;i++)
{
string pp={};
for(int j=0;j<i;j++)pp+=s[j];
pp+=a;
for(int j=0;j<i;j++)pp+=s[j];
pp+=b;
pp+=a;
for(int j=0;j<i;j++)pp+=s[j];
pp+=b;
pp+=b;
for(int j=0;j<i;j++)pp+=s[j];
pp+=b;
pp+=c;
int x=press(pp);
if(x==i+1)s+=a;
else if(x==i+2)s+=b;
else s+=c;
}
string x;
for(int i=0;i<N-1;i++)x+=s[i];
x+=a;
if(press(x)==N)s+=a;
else
{
string k;
for(int i=0;i<N-1;i++)k+=s[i];
k+=b;
if(press(k)==N)s+=b;
else s+=c;
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |