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 int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
#include "combo.h"
using namespace std;
ll n,m,sum,t;
string tut="ABXY";
string s;
char tutt;
ll tutmac;
string f1()
{
string ss="AB";;
ll a=press(ss);
ss="AX";
ll b=press(ss);
if(a)
{
if(b)
return "A";
return "B";
}
if(b)
return "X";
return "Y";
}
string end()
{
// cout<<s<<endl;
string ss=s+"A"+s+"B";
ll a=press(ss);
ss=s+"A"+s+"X";
ll b=press(ss);
if(a==n)
{
if(b==n)
return "A";
return "B";
}
if(b==n)
return "X";
return "Y";
}
ll ask1()
{
string p="";
fo(i,0,3)
{
if(tutmac==i)
continue;
p=p+s+"A"+tut[i];
}
p=p+s+"B";
return press(p)-s.size();
}
ll ask2()
{
string p="";
fo(i,0,3)
{
if(tutmac==i)
continue;
p=p+s+"X"+tut[i];
}
p=p+s+"Y";
return press(p)-s.size();
}
void ask()
{
fo(i,0,3)
if(s[0]==tut[i])
tutmac=i;
// cout<<tutmac<<endl;
ll x=0;
if(tutmac>=2)
{
x=ask1();
ll y=2;
if(tutmac==y)
y++;
if(x==0)
{
s+=tut[y];
}
if(x==1)
s+=tut[1];
if(x==2)
s+=tut[0];
return;
}
x=ask2();
// cout<<x<<endl;
ll y=0;
if(y==tutmac)
y++;
if(x==0)
{
s+=tut[y];
}
if(x==1)
s+=tut[3];
if(x==2)
s+=tut[2];
}
string guess_sequence(int nn)
{
n=nn;
s=f1();
tutmac=s[0];
string p = s;
// cout<<s<<endl;
if(n==1)
return s;
fo(i,2,n-1)
{
ask();
}
// cout<<s<<endl;
string xx=end();
s=s+xx;
// cout<<s<<endl;
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |