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 <string>
#include "combo.h"
#include <iostream>
using namespace std;
string guess_sequence(int N)
{
int ab = press("AB");
char first;
string l[3];
if (ab > 0)
{
if (press("A") > 0)
{
first = 'A';
l[0] = "B";
l[1] = "X";
l[2] = "Y";
}
else
{
first = 'B';
l[0] = "A";
l[1] = "X";
l[2] = "Y";
}
}
else
{
if (press("X") > 0)
{
first = 'X';
l[0] = "A";
l[1] = "B";
l[2] = "Y";
}
else
{
first = 'Y';
l[0] = "A";
l[1] = "B";
l[2] = "X";
}
}
string p = "";
p += first;
int m = 1;
for (int i = 1; i < N - 1; i++)
{
string tmp = (p + l[0] + l[0]) + (p + l[0] + l[1]) + (p + l[0] + l[2]) + (p + l[1]);
int x = press(tmp);
if (x - m == 2)
{
p = p + l[0];
}
else if (x - m == 1)
{
p = p + l[1];
}
else
{
p = p + l[2];
}
m++;
}
if (N != 1)
{
if (press(p + l[0]) > m)
{
p = p + l[0];
}
else if (press(p + l[1]) > m)
{
p = p + l[1];
}
else
{
p = p + l[2];
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |