# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78790 | patcasrares | 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<iostream>
#include "combo.h"
using namespace std;
int press2(string s,int n)
{
//cout<<s.size()<<' '<<4*n<<'\n';
if(s.size()>4*n)
while(1){}
return press(s);
}
string guess_sequence(int N)
{
int r,poz=0,cnt=-1;
string a[3],cand[4]={"A","B","X","Y"};
string q,rez;
q="AB";
r=press2(q,n);
if(r)
poz=0;
else
poz=2;
q=cand[poz];
r=press2(q,n);
if(r==0)
poz++;
for(int i=0;i<4;i++)
if(i!=poz)
{
cnt++;
a[cnt]=cand[i];
}
rez=cand[poz];
cnt=1;
poz=2;
for(int i=2;i<n;i++)
{
q=rez+a[0]+rez+a[1]+a[0]+rez+a[1]+a[1]+rez+a[1]+a[2];
r=press2(q,n);
if(r==i-1)
{
rez=rez+a[2];
continue;
}
if(r==i)
{
rez=rez+a[0];
continue;
}
rez=rez+a[1];
if(press(rez)!=i)
while(1){}
}
q=rez+a[0]+rez+a[1];
r=press2(q,n);
if(r==n)
{
q=rez+a[0];
r=press2(q,n);
if(r==n)
rez=rez+a[0];
else
rez=rez+a[1];
}
else
rez=rez+a[2];
return rez;
}