#include "bits/stdc++.h"
#include "combo.h"
// #include "grader.cpp"
using namespace std;
int vis[50];
vector <char> v = {'A', 'B', 'X', 'Y'};
string find_f(string g) {
int nd = press(g);
if(nd == 1) {
string h = "";
nd = press(h + g[0]);
if(nd == 1) return h + g[0];
else return h + g[1];
}
if(nd == 0) {
string h = "";
int cnt = 0;
for(auto i : v) {
cnt++;
if(i == g[0] || i == g[1]) continue;
if(cnt == 4) return h + i;
nd = press(h + i);
if(nd) return h + i;
}
}
return g;
}
string guess_sequence(int N) {
string S = find_f("AB"), h = "";
for(auto i : v) {
if(i != S[0]) h += i;
}
while(1) {
string g = S;
for(int i = 0; i <= 2; i++) {
g += h[0];
g += h[i];
g += S;
}
g += h[2];
if((int)g.size() > N * 4) break;
int nd = press(g);
if(nd == (int)S.size() + 1) {
S += h[2];
}
else if(nd == (int)S.size() + 2) {
S += h[0];
}
else {
S += h[1];
}
}
if((int)S.size() == N) return S;
int c = 0;
for(auto i : h) {
c++;
if(c == 3) return S + i;
int nd = press(S + i);
if(nd == (int)S.size() + 1) return S + i;
}
return S;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |