# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1271209 | mkkkkkkkk | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N)
{
char c=NULL;
int br=press("AB");
if(br==1)
{
br=press("A");
if(br==1)
c='A';
else
c='B';
}
else
{
br=press("X");
if(br==1)
c='X';
else
c='Y';
}
string possible="";
if(c!='A')
possible.push_back('A');
if(c!='B')
possible.push_back('B');
if(c!='X')
possible.push_back('X');
if(c!='Y')
possible.push_back('Y');
string res="";
res.push_back(c);
for(int i=1;i<N-1;i++)
{
string temp="";
temp+=res;
temp.push_back(possible[0]);
temp.push_back(possible[0]);
temp+=res;
temp.push_back(possible[0]);
temp.push_back(possible[1]);
temp+=res;
temp.push_back(possible[0]);
temp.push_back(possible[2]);
temp+=res;
temp.push_back(possible[1]);
br=press(temp);
if(br==i+1)
{
res.push_back(possible[1]);
}
else if(br==i+2)
{
res.push_back(possible[0]);
}
else
{
res.push_back(possible[2]);
}
}
br=press(res+"AB");
if(br==1)
{
br=press(res+"A");
if(br==N)
res.push_back('A');
else
res.push_back('B');
}
else
{
br=press(res+"X");
if(br==N)
res.push_back('X');
else
res.push_back('Y');
}
return res;
}