#include "combo.h"
using namespace std;
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using str = string; // yay python!
#define sz(x) ll(x.size())
#define all(x) x.begin(), x.end()
#define show(x) cerr << (#x) << " = " << (x) << '\n';
#define output_vector(v) for(auto &x : v){cout << x << ' ';}cout << '\n';
std::string guess_sequence(int N) {
vector<char> butt = {'A', 'B', 'X', 'Y'};
int x = press("AB");
char first;
if(x) {
x = press("A");
if(x) first = 'A';
else first = 'B';
} else {
x = press("X");
if(x) first = 'X';
else first = 'Y';
}
str ans = "", s = "";
ans += first;
s += first;
if(N == 1) {
return s;
}
butt.erase(find(all(butt), first));
for(int i=1; i<N-1; ++i) {
char k = butt[0];
str p = "";
for(auto &v : butt) {
p += s + k + v;
}
p += s + butt[1];
x = press(p);
if(x >= sz(s) + 2) {
s += butt[0];
} else if(x >= sz(s) + 1) {
s += butt[1];
} else {
s += butt[2];
}
}
x = press(s + butt[0]);
if(x == N)
s += butt[0];
else {
x = press(s + butt[1]);
if(x == N)
s += butt[1];
else
s += butt[2];
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |