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;
string guess_sequence(int N) {
string f;
vector<char> letter;
if (press("AB") != 0) {
if (press("A") == 1) {
f = "A";
letter = { 'B', 'X', 'Y' };
}
else {
f = "B";
letter = { 'A', 'X', 'Y' };
}
}
else {
if (press("X") == 1) {
f = "X";
letter = { 'B', 'A', 'Y' };
}
else {
f = "Y";
letter = { 'B', 'X', 'A' };
}
}
int l = 1;
string result = f;
string testcase;
while (true) {
testcase = result + letter[0] + letter[1] + result + letter[1] + letter[0];
int outcome = press(testcase);
if (outcome == l) {
result += letter[2];
l += 1;
}
else if (outcome == l + 2) {
testcase = result;
testcase += letter[0] + letter[1];
if (press(testcase) == l) {
result += letter[1] + letter[0];
}
else {
result += letter[0] + letter[1];
}
l += 2;
}
else {
testcase = result;
testcase += letter[0] + letter[2];
if (press(testcase) == l) {
result += letter[1] + letter[2];
}
else {
result += letter[0] + letter[2];
}
l += 2;
}
if (l == N || l == N - 1) {
break;
}
}
if (l == N) {
return result;
}
string testcase1;
testcase1 = result + letter[0];
if (press(testcase1) > l) {
return testcase1;
}
testcase1 = result + letter[0];
if (press(testcase1) > l) {
return testcase1;
}
result += letter[2];
return result;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |