#include <bits/stdc++.h>
using namespace std;
#include "combo.h"
// const string S = "A";
// int queries = 0;
// int press(string p) {
// queries++;
// int n = S.size();
// for (int i = n; i > 0; i--) {
// if (p.find(S.substr(0, i)) != string::npos) {
// return i;
// }
// }
// return 0;
// }
char chars[] = "ABXY";
string guess_sequence(int n) {
for (int i = 0; i < 3; i++)
if (press({chars[i]}) == 1) {
swap(chars[i], chars[3]);
break;
}
string res = {chars[3]};
for (int i = 1; i < n-1; i++) {
string p = res + chars[0];
for (int i = 0; i < 3; i++) p += res + chars[1] + chars[i];
int x = press(p);
res += chars[(x == i) ? 2 : (x == i + 1) ? 0 : 1];
}
if (n == 1) return res;
for (int i = 0; i < 2; i++) {
if (press(res + chars[i]) == n) {
res += chars[i];
break;
}
}
if (res.size() < n) res += chars[2];
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |