#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
typedef long long ll;
typedef map<ll, ll> mp;
typedef pair<ll, ll> pll;
typedef queue<ll> qi;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector <vi> vvi;
typedef vector <pll> vpl;
typedef vector <string> vs;
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define F first
#define S second
#define pb push_back
#define all(x) begin(x), end(x)
string guess_sequence(int N) {
string ans;
if (press("AB")) {
if (press("A")) ans = "A";
else ans = "B";
} else {
if (press("X")) ans = "X";
else ans = "Y";
}
if (N == 1) return ans;
char p[3];
int k = 0;
for (char c : {'A', 'B', 'X', 'Y'}) {
if (c != ans[0]) p[k++] = c;
}
for (int i = 1; i < N - 1; ++i) {
string ask = ans + p[0] + ans + p[1] + p[0] + ans + p[1] + p[1] + ans + p[1] + p[2];
int q = press(ask);
if (q == i + 2) ans += p[1];
else if (q == i + 1) ans += p[0];
else ans += p[2];
}
if (press(ans + p[0]) == N) ans += p[0];
else if (press(ans + p[1]) == N) ans += p[1];
else ans += p[2];
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |