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 <bits/stdc++.h>
using namespace std;
int press(string);
string guess_sequence(int N)
{
string p = "", c = "";
if (press("AB") > 0)
if (press("A") > 0) p = "A", c = "BXY";
else p = "B", c = "AXY";
else
if (press("X") > 0) p = "X", c = "ABY";
else p = "Y", c = "ABX";
int x = 1;
while (x < N - 1) {
string pp = p + c[0]; // c[0] return x + 1
pp += p + c[1] + c[0]; // c[1] return x + 2
pp += p + c[1] + c[1]; // c[2] return x
pp += p + c[1] + c[2];
int xx = press(pp);
if (xx == x) p = p + c[2];
else if (xx == x + 1) p = p + c[0];
else p = p + c[1];
x++;
}
if (x < N) {
if (press(p + c[0]) > x) p = p + c[0];
else if (press(p + c[1]) > x) p = p + c[1];
else p = p + c[2];
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |