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>
std::string guess_sequence(int N) {
char firstC;
if (press("AB") >= 1) {
if (press("A") == 1) {
firstC = 'A';
} else {
firstC = 'B';
}
} else {
if (press("X") == 1) {
firstC = 'X';
} else {
firstC = 'Y';
}
}
std::vector<char> cs = {'A', 'B', 'X', 'Y'};
for (int i = 0; i < 4; ++i) {
if (cs[i] == firstC) {
cs.erase(cs.begin() + i);
break;
}
}
std::string answer = "";
answer += firstC;
for (int i = 1; i < N - 1; ++i) {
std::string x = answer;
x += cs[1];
x += answer;
x += cs[0];
x += cs[0];
x += answer;
x += cs[0];
x += cs[1];
x += answer;
x += cs[0];
x += cs[2];
const auto res = press(x);
if (res == i) {
answer += cs[2];
} else if (res == i + 1) {
answer += cs[1];
} else {
answer += cs[0];
}
}
if (press(answer + 'A' + answer + 'B') == N) {
if (press(answer + 'A') == N) {
answer += 'A';
} else {
answer += 'B';
}
} else {
if (press(answer + 'X') == N) {
answer += 'X';
} else {
answer += 'Y';
}
}
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |