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 <vector>
#include <string>
#include <algorithm>
std::string guess_sequence(int N) {
static const char buttons[] = { 'A', 'B', 'X', 'Y' };
int first;
if (press(std::string { buttons[0], buttons[1] })) {
if (press(std::string { buttons[0] })) {
first = 0;
} else {
first = 1;
}
} else {
if (press(std::string { buttons[2] })) {
first = 2;
} else {
first = 3;
}
}
char Y = buttons[first];
char A = buttons[(first + 1) & 3];
char B = buttons[(first + 2) & 3];
char X = buttons[(first + 3) & 3];
std::string S { Y };
for (int i = 1; i < N; ++i) {
if (press(S + A + S + B) == i + 1) {
if (press(S + A) == i + 1) {
S += A;
} else {
S += B;
}
} else {
if (press(S + B) == i + 1) {
S += B;
} else {
S += X;
}
}
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |