# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
191324 | anubhavdhar | Combo (IOI18_combo) | C++14 | 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>
#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(i=0;i<n;i++)
#define FORe(i,n) for(i=1;i<=n;i++)
#define FORr(i,a,b) for(i=a;i<b;i++)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first
#define ss second
#define cd complex<double>
#define vcd vector<cd>
using namespace std;
/*
const ll MAXN = 2e5+5;
const ll MOD = 1e9+7;
const ll ROOTN = 320;
const ll LOGN = 17;
const ll INF = 1e17 + 1101;
inline int press(string S)
{
cout<<"pressing : "<<S<<endl;
ll p;
cin>>p;
return p;
}*/
char guess_first_char()
{
ll i = press("XY");
if (i)
{
if (press("X"))
return 'X';
return 'Y';
}
else
{
if (press("A"))
return 'A';
return 'B';
}
}
string guess_sequence(int N)
{
char P[3],c = guess_first_char();
ll i = 0,sz;
string S = "";
S += c;
for(char dd : {'A','B','X','Y'})
if (dd != c)
P[i++] = dd;
FORe(i,N-2)
{
sz = press(S+P[0]+S+P[1]+P[0]+S+P[1]+P[1]+S+P[1]+P[2]);
if (sz == S.size())
S += P[2];
else if(sz == S.size() + 1)
S += P[0];
else if(sz == S.size() + 2)
S += P[1];
else
return "SHOULDNOTBEOUTPUT";
}
if (N == press(S+P[0]))
S+=P[0];
else if(N == press(S+P[1]))
S+=P[1];
else
S+=P[2];
return S;
}
/*
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll N;
cin>>N;
cout<<"output :"<<guess_sequence(N);
return 0;
}*/