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>
using namespace std;
std::string guess_sequence(int N) {
string S;
if (press("AB")) {
if (press("A")) S.push_back('A');
else S.push_back('B');
} else if (press("X")) S.push_back('X');
else S.push_back('Y');
vector<char> ot;
if (S[0] != 'A') ot.push_back('A');
if (S[0] != 'B') ot.push_back('B');
if (S[0] != 'X') ot.push_back('X');
if (S[0] != 'Y') ot.push_back('Y');
for (int i = 1; i < N - 1; i++) {
string guess = S;
guess.push_back(ot[0]); guess.push_back(ot[0]);
guess += S;
guess.push_back(ot[0]); guess.push_back(ot[1]);
guess += S;
guess.push_back(ot[0]); guess.push_back(ot[2]);
guess += S;
guess.push_back(ot[1]);
int p = press(guess);
if (p == i + 1) S.push_back(ot[1]);
else if (p == i + 2) S.push_back(ot[0]);
else S.push_back(ot[2]);
}
if (N > 1) {
S.push_back(ot[0]);
if (press(S) == N) return S;
S.back() = ot[1];
if (press(S) == N) return S;
S.back() = ot[2];
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |