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"
using namespace std;
string guess_sequence(int N)
{
string S = "";
string chrs;
switch (press("AB"))
{
case 1:
if (press("A"))
{
S = "A";
chrs = "BXY";
}
else
{
S = "B";
chrs = "AXY";
}
break;
case 2:
S = "AB";
chrs = "BXY";
break;
default:
if (press("X"))
{
S = "X";
chrs = "ABY";
}
else
{
S = "Y";
chrs = "ABX";
}
break;
}
int len = S.size();
while (len < N - 1)
{
string query = S + chrs[0] + S + chrs[1] + chrs[0] + S + chrs[1] + chrs[1] + S + chrs[1] + chrs[2];
int res = press(query);
if (res == len)
{
S += chrs[2];
}
else if (res == len + 1)
{
S += chrs[0];
}
else
{
S += chrs[1];
}
len++;
}
if (len != N)
{
if (press(S + chrs[0]) == len + 1) return S + chrs[0];
else if (press(S + chrs[1]) == len + 1) return S + chrs[1];
else return S + chrs[2];
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |