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>
using namespace std;
std::string guess_sequence(int N)
{
vector<string> a(0);
string prefix = "";
if(press("AB") > 0)
{
if(press("A") == 1)
{
a = {"B", "X", "Y"};
prefix = "A";
}
else
{
a = {"A", "X", "Y"};
prefix = "B";
}
}
else
{
if(press("X") == 1)
{
a = {"B", "A", "Y"};
prefix = "X";
}
else
{
a = {"A", "X", "B"};
prefix = "Y";
}
}
if(N == 1)
{
return prefix;
}
while((int) prefix.length() < N-1)
{
string q = prefix + a[1] + prefix + a[2] + a[0] + prefix + a[2] + a[1] + prefix + a[2] + a[2];
int res = press(q);
if(res == (int) prefix.length())
{
prefix += a[0];
}
else if(res == (int) prefix.length()+1)
{
prefix += a[1];
}
else
{
prefix += a[2];
}
}
int index = 0;
while(press(prefix+a[index]) < N)
{
index++;
}
prefix += a[index];
return prefix;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |