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