#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
string g = "";
int k = press("AB");
if(k) {
k = press("A");
if(k) g = "A";
else g = "B";
}
else {
k = press("X");
if(k) g = "X";
else g = "Y";
}
if(n == 1) return g;
vector<char> dd = {'A', 'B', 'X', 'Y'}, nw;
for(char i: dd) if(i != g[0]) nw.push_back(i);
for(int i = 1 ; i < n-1 ; i++) {
string p = g + nw[0] + g + nw[1] + nw[0] + g + nw[1] + nw[1] + g + nw[1] + nw[2];
// cout << p << endl;
int m = press(p);
m -= i;
if(m == 0) g.push_back(nw[2]);
else if(m == 1) g.push_back(nw[0]);
else g.push_back(nw[1]);
}
k = press(g + nw[0] + g + nw[1]);
if(k == n) {
// g.push_back(nw[2]);
k = press(g + nw[0]);
if(k == n) g.push_back(nw[0]);
else g.push_back(nw[1]);
}
else g.push_back(nw[2]);
return g;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |