#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(), a.end()
// const int MOD = 1e9 + 7,INF = 1e18;
string guess_sequence(int n) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s = "";
string ans = "";
string a , b , c;
int t = press("AB");
if(t > 0){
int f = press("A");
if(f == 1){
ans += "A";
a = "B";
b = "X";
c = "Y";
}
else{
ans += "B";
a = "A";
b = "X";
c = "Y";
}
}
else{
int f = press("X");
if(f == 1){
ans += "X";
a = "B";
b = "A";
c = "Y";
}
else{
ans += "Y";
a = "B";
b = "X";
c = "A";
}
}
while(ans.size() != n){
string d = ans + a + a + ans + a + b + ans + b + c;
if(d.size() > 4 * n){
while(true);
}
int h = press(d);
h -= ans.size();
if(h == 0){
ans += c;
}
if(h == 1){
if(ans.size() + 1 == n){
int j = press(ans + a);
j -= ans.size();
if(j == 1){
ans += a;
}
else{
ans += b;
}
break;
}
int j = press(ans + b + b);
j -= ans.size();
if(j == 0){
ans += a + c;
}
if(j == 1){
ans += b + a;
}
if(j == 2){
ans += b + b;
}
}
if(h == 2){
int j = press(ans + a + a);
j -= ans.size();
if(j == 0){
ans += b + c;
}
if(j == 1){
ans += a + b;
}
if(j == 2){
ans += a + a;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |