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>
#include <assert.h>
#include <iostream>
std::string guess_sequence(int N) {
std::vector<char> buttons = { 'A', 'B', 'X', 'Y' };
int first;
if (press({ buttons[0], buttons[1] })) {
if (press({ buttons[0] })) {
first = 0;
} else {
first = 1;
}
} else {
if (press({ buttons[2] })) {
first = 2;
} else {
first = 3;
}
}
char Y = buttons[first];
char A = buttons[(first + 1) % 4];
char B = buttons[(first + 2) % 4];
char X = buttons[(first + 3) % 4];
std::string S = { Y };
while ((int) S.size() < N - 1) {
std::string p = S + A + A + S + A + B + S + A + X + S + B;
// std::cerr << S << " " << p << "\n";
int coins = press(p);
int matching = coins - (int) S.size();
if (matching == 0) {
S += X;
} else if (matching == 1) {
S += B;
} else {
S += A;
}
}
if ((int) S.size() < N) {
if (press(S + A) == N) {
S += A;
} else if (press(S + B) == N) {
S += B;
} else {
S += X;
}
}
std::cerr << S << "\n";
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |