#include <bits/stdc++.h>
using namespace std;
#include "combo.h"
std::string guess_sequence(int N) {
char ez[4] = {'A', 'B', 'X', 'Y'};
vector<char> v;
char st, ed;
string now;
if (press("AB") >= 1) {
if (press("A") == 1) st = 'A';
else st = 'B';
}
else {
if (press("X") == 1) st = 'X';
else st = 'Y';
}
now += st;
v.clear();
for (int i = 0; i < 4; i++) if (ez[i] != st) v.push_back(ez[i]);
for (int i = 1; i < N-1; i++) {
string s;
for (char c : v) {
s += now + string(1,v[0]) + string(1,c);
}
s += now + string(1,v[1]);
int z = press(s);
if (z == i+2) now.push_back(v[0]);
else if (z == i+1) now.push_back(v[1]);
else now.push_back(v[2]);
}
if (N > 1) {
if (press(now+string(1,v[0])) == N) now.push_back(v[0]);
else if (press(now+string(1,v[1])) == N) now.push_back(v[1]);
else now.push_back(v[2]);
}
return now;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |