#pragma GCC optimize("O3")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
using namespace std;
int press(string s);
const char c[] = {'A','B','X','Y'};
int ask(string s) {return press(s);}
string guess_sequence(int n) {
if (n == 1) return ask("A") ? "A" : ask("B") ? "B" : ask("X") ? "X" : "Y";
string s = "";
int idx[4];
iota(idx, idx+4, 0);
int id = ask("AB") ? (ask("A") ? 0 : 1) : (ask("X") ? 2 : 3);
s += c[id], swap(idx[id],idx[3]);
for (int i = 1; i < n-1; i++) s += ask(s+c[idx[0]]) == i+1 ? c[idx[0]] : ask(s+c[idx[1]]) == i+1 ? c[idx[1]] : c[idx[2]];
s += ask(s+c[idx[0]]) == n ? c[idx[0]] : ask(s+c[idx[1]]) == n ? c[idx[1]] : c[idx[2]];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |