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 = 0;
while (first < 3 && press({ buttons[first] }) == 0) {
++first;
}
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... |