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 <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
char a, b, c, d;
if (press("AB")) {
if (press("A")) {
a = 'A';
b = 'B';
c = 'X';
d = 'Y';
}
else {
a = 'B';
b = 'A';
c = 'X';
d = 'Y';
}
}
else {
if (press("X")) {
a = 'X';
b = 'B';
c = 'A';
d = 'Y';
}
else {
a = 'Y';
b = 'B';
c = 'X';
d = 'A';
}
}
int i;
string S;
S += a;
if (N == 1) return S;
for (i = 2; i <= N - 1; i++) {
string g1, g2, g3, g4;
string g;
g = S + b;
g1 = g + b;
g2 = g + c;
g3 = g + d;
g4 = S + c;
int res = press(g1 + g2 + g3 + g4);
if (res == i + 1) S += b;
if (res == i) S += c;
if (res == i - 1) S += d;
}
if (press(S + b) == N) return S + b;
if (press(S + c) == N) return S + c;
return S + d;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |