#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
// int press(string p){
// cout << p << endl;
// int c; cin >> c;
// return c;
// }
// int main(){ int n; cin >> n;
string guess_sequence(int n){
vector<string> b = {"A", "B", "X", "Y"};
string fi;
int x = press("AB");
if (x > 0){
x = press("A");
if (x > 0) fi = "A";
else fi = "B";
}
else {
x = press("X");
if (x > 0) fi = "X";
else fi = "Y";
}
string ans;
vector<string> c;
for (auto i : b){
if (i != fi) c.push_back(i);
}
for (int i = 2; i < n; i++){
string query = fi + ans + c[0];
for (auto j : c){
query += fi + ans + c[1] + j;
}
x = press(query);
if (x == i) ans += c[0];
else if (x >= i + 1) ans += c[1];
else ans += c[2];
}
string q1 = fi + ans + c[0], q2 = fi + ans + c[1];
x = press(q1);
if (x == n){
return q1;
// cout << q1 << endl;
// return 0;
}
x = press(q2);
if (x == n){
return q2;
// cout << q2 << endl;
// return 0;
}
return fi + ans + c[2];
// cout << fi + ans + c[2] << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |