#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <cassert>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;
#define endl "\n"
// #define int long long
const int INF = 1e9+7;
const int MOD = 1e9+7;
// int press(string p){cout << p << " "; int nr; cin >> nr; return nr;};
int press(string p);
string guess_sequence(int n){
    string sol;
    vector<char> ops;
    if(press("A") == 1){sol+='A'; ops = {'B', 'X', 'Y'};}
    else if(press("B") == 1){sol+='B'; ops = {'A', 'X', 'Y'};}
    else if(press("X") == 1){sol+='X'; ops = {'A', 'B', 'Y'};}
    else {sol+="Y"; ops = {'A', 'B', 'X'};}
    while(sol.size() < n){
        // randomize:
        random_device rd;
        mt19937 g(rd());
        shuffle(ops.begin(), ops.end(), g);
        int ans1 = press(sol + string(n, ops[0]));
        if(ans1 != sol.size()){
            sol += string(ans1 - sol.size(), ops[0]);
            continue;
        }
        int ans2 = press(sol + string(n, ops[1]));
        if(ans2 != sol.size()){
            sol += string(ans2 - sol.size(), ops[1]);
            continue;
        }
        int ans3 = press(sol + string(n, ops[2]));
        sol += string(ans3 - sol.size(), ops[2]);
    }
    return sol;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |