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>
#define ll long long
#define db long double
//#define N 505
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define IDB pair <db,int>
#define TII pair <treap*,treap*>
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x)
using namespace std;
#include "combo.h"
//#define press(s) IR.cal(s)
struct Interactive
{
int n;
string s;
void Init(int _n)
{
n=_n;
cin>>s;
}
int cal(string a)
{
for(int i=n;i>=1;i--)
if(a.find(s.substr(0,i))!=a.npos)
return i;
return 0;
}
} IR;
string guess_sequence(int n)
{
if(n==1)
{
if(press("A")) return "A";
if(press("B")) return "B";
if(press("X")) return "X";
return "Y";
}
string s;
int k=press("BXBY");
if(k==0) s="A";
else if(k==1)
{
k=press("BAX");
if(k==0) s="Y";
else if(k==1) s="X";
else s="B";
}
else s=(press("B") ? "B" : "X");
string t;
if(s=="A") t="BXY";
else if(s=="B") t="XYA";
else if(s=="X") t="YAB";
else t="ABX";
for(int i=2;i<n;i++)
{
string now="";
now+=s; now+=t[0];
now+=s; now+=t[1]; now+=t[0];
now+=s; now+=t[1]; now+=t[1];
now+=s; now+=t[1]; now+=t[2];
k=press(now);
if(k==s.size()) s+=t[2];
else if(k==s.size()+2) s+=t[1];
else s+=t[0];
}
if(press(s+t[0])==n) s+=t[0];
else if(press(s+t[1])==n) s+=t[1];
else s+=t[2];
return s;
}
/*
int main()
{
freopen("combo.inp","r",stdin);
freopen("combo.out","w",stdout);
int n;
cin>>n;
IR.Init(n);
cout<<guess_sequense(n);
}
*/
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:72:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | if(k==s.size()) s+=t[2];
| ~^~~~~~~~~~
combo.cpp:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | else if(k==s.size()+2) s+=t[1];
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |