# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1271601 | david_g611 | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N)
{
char first;
if(press("AB"))
{
if(press("A"))
first='A';
else
first='B';
}
else
{
if(press("X"))
first='X';
else
first='Y';
}
string s="";
s+=first;
char f1, f2, f3;
if(first=='A')f1='B', f2='X', f3='Y';
if(first=='B')f1='A', f2='X', f3='Y';
if(first=='X')f1='B', f2='Y', f3='A';
if(first=='Y')f1='B', f2='X', f3='A';
for(int i=2; i<=N-1; i++)
{
string p="";
p+=s;p+=f1;p+=f1;
p+=s;p+=f1;p+=f2;
p+=s;p+=f1;p+=f3;
p+=s;p+=f2;
int creste=press(p)-s.size();
if(creste==2)s+=f1;
if(creste==1)s+=f2;
if(creste==0)s+=f3;
}
string p="";
p=s+f1+s+f2;
if(press(p) == N)
{
p=s+f1;
if(press(p)==N)
s+=f1;
else
s+=f2;
}
else
s+=f3;
return s;
}