#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string guess_sequence(int N) {
vector<string> buttons = { "A", "B", "X", "Y" };
string s;
shuffle(buttons.begin(), buttons.end(), rng);
s = buttons.back();
for (int i = 0; i < 3; i++) {
if (press(buttons[i]) == 1) {
s = buttons[i];
break;
}
}
for (int i = 0; i < 4; i++) {
if (buttons[i] == s) {
buttons.erase(buttons.begin() + i);
break;
}
}
for (int i = 1; i < N - 1; i++) {
shuffle(buttons.begin(), buttons.end(), rng);
string p = s;
p += buttons[0];
for (int j = 0; j < 3; j++) {
p += s;
p += buttons[1];
p += buttons[j];
}
int x = press(p);
if (x == i + 1) {
s += buttons[0];
} else if (x == i + 2) {
s += buttons[1];
} else {
s += buttons[2];
}
}
shuffle(buttons.begin(), buttons.end(), rng);
if (press(s + buttons[0]) == N) {
s += buttons[0];
} else if (press(s + buttons[1]) == N) {
s += buttons[1];
} else {
s += buttons[2];
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |