#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string K = "";
char first;
// find first;
if (press("AB") >= 1) {
if (press("A") >= 1) {
K += 'A';
} else {
K += 'B';
}
} else {
if (press("X") >= 1) K += 'X';
else K += 'Y';
}
first = K[0];
for (int i = 0; i < N - 1; i++) {
string p = "";
if (first == 'A') {
if (i == N - 2) {
int x = press(K + "B" + K + "X"), y = press(K + "B" + K + "Y");
if (x == y) K += 'B';
else if (x == N) K += 'X';
else K += 'Y';
continue;
}
p = K + "B" + K + "XB" + K + "XX" + K + "XY";
int x = press(p);
if (x == K.size()) {
K += 'Y';
} else if (x == K.size() + 1) {
K += 'B';
} else K += 'X';
} else if (first == 'B') {
if (i == N - 2) {
int x = press(K + "X" + K + "Y"), y = press(K + "X" + K + "A");
if (x == y) K += 'X';
else if (x == N) K += 'Y';
else K += 'A';
continue;
}
p = K + "X" + K + "YX" + K + "YY" + K + "YA";
int x = press(p);
if (x == K.size()) {
K += 'A';
} else if (x == K.size() + 1) {
K += 'X';
} else K += 'Y';
} else if (first == 'X') {
if (i == N - 2) {
int x = press(K + "Y" + K + "A"), y = press(K + "Y" + K + "B");
if (x == y) K += 'Y';
else if (x == N) K += 'A';
else K += 'B';
continue;
}
p = K + "Y" + K + "AY" + K + "AA" + K + "AB";
int x = press(p);
if (x == K.size()) {
K += 'B';
} else if (x == K.size() + 1) {
K += 'Y';
} else K += 'A';
} else {
if (i == N - 2) {
int x = press(K + "A" + K + "B"), y = press(K + "A" + K + "X");
if (x == y) K += 'A';
else if (x == N) K += 'B';
else K += 'X';
continue;
}
p = K + "A" + K + "BA" + K + "BB" + K + "BX";
int x = press(p);
if (x == K.size()) {
K += 'X';
} else if (x == K.size() + 1) {
K += 'A';
} else K += 'B';
}
}
//cout << K << "\n";
return K;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |