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 <iostream>
#include <cassert>
using namespace std;
int q = 0;
int ask(string s) {
++q;
assert(q <= 8000);
//cout << "PRESS " << s << endl;
return press(s);
}
std::string guess_sequence(int N) {
string A[] = { "A", "B", "X", "Y" };
string S = "";
if (ask(A[0] + A[1])) {
if (ask(A[0])) {
S += A[0];
} else {
S += A[1];
swap(A[1],A[0]);
}
} else {
if (ask(A[2])) {
S += A[2];
swap(A[2],A[0]);
} else {
S += A[3];
swap(A[2],A[0]);
}
}
if (N == 1) return S;
for (int i = 1; i <= N-2; ++i) {
string a = S + A[3] + A[1];
string b = S + A[3] + A[2];
string c = S + A[3] + A[3];
string d = S + A[2];
int x = ask(a + b + c + d);
S += A[x-i+1];
}
if (ask(S + A[1]) == N) S += A[1];
else if (ask(S + A[2]) == N) S += A[2];
else S += A[3];
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |