# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
770712 | AtinaR | 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 "combo.h"
#include <bits/stdc++.h>
std::string guess_sequence(int N)
{
char first;
int f=press("AB");
if(f>=1)
{
f=press("A");
if(f>=1)
{
first='A';
}
else
{
first='B';
}
}
else
{
f=press("X");
if(f>=1)
{
first='X';
}
else first='Y';
}
string res="";
res+=first;
char possible[3];
if(first=='X')
{
possible[0]='A';
possible[1]='B';
possible[2]='Y';
}
else if(first=='Y')
{
possible[0]='A';
possible[1]='B';
possible[2]='X';
}
else if(first=='A')
{
possible[0]='X';
possible[1]='B';
possible[2]='Y';
}
else if(first=='B')
{
possible[0]='A';
possible[1]='X';
possible[2]='Y';
}
while(res.size()<N)
{
int tmp;
string A=res+possible[0];
string B=res+possible[1];
string C=res+possible[2];
tmp=press(A);
if(tmp==A.size())
{
res=A;
continue;
}
tmp=press(B);
if(tmp==B.size())
{
res=B;
continue;
}
res=C;
}
return res;
}