#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
char f, a, b, c;
int val;
string ans, t;
val = press("AB");
if(val) {
a = 'X';
b = 'Y';
val = press("A");
f = (val ? 'A' : 'B');
c = (!val ? 'A' : 'B');
} else {
a = 'A';
b = 'B';
val = press("X");
f = (val ? 'X' : 'Y');
c = (!val ? 'X' : 'Y');
}
ans.push_back(f);
for(int i=2; i<n; i++) {
t.clear();
t += ans + a + b;
t += ans + a + c;
t += ans + b;
val = press(t);
if(val == i+1) {
ans.push_back(a);
} else if(val == i) {
ans.push_back(b);
} else {
ans.push_back(c);
}
}
val = press(ans + a);
if(val == n) return ans + a;
val = press(ans + b);
if(val == n) return ans + b;
return ans + c;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |