#include "combo.h"
std::string guess_sequence(int N) {
int id_first_char;
char ch[] = {'A', 'B', 'X', 'Y'};
std::string s = "";
if (press("AB") > 0) {
id_first_char = (press("A") == 0);
}
else {
id_first_char = 2 + (press("X") == 0);
}
s += ch[id_first_char];
if (N == 1) return s;
std::swap(ch[id_first_char], ch[3]);
for (int i = 1; i < N - 1; i++) {
int x = press(s + ch[0] + ch[0] + s + ch[0] + ch[1] + s + ch[0] + ch[2] + s + ch[1]);
if (x == i + 2) s+=ch[0];
else if (x == i + 1) s+=ch[1];
else s += ch[2];
}
if (press(s + ch[0]) == N) {
s += ch[0];
} else if (press(s + ch[1]) == N) {
s += ch[1];
} else {
s += ch[2];
}
return s;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |