#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string ans;
int r = press("AB");
if(r==2) ans = "AB";
else if(r==1) ans = (press("A") == 1) ? "A" : "B";
else ans = (press("X")==1) ? "X" : "Y";
if(ans.size()==N) return ans;
vector<char> others;
for(char c : {'A','B','X','Y'})
if(c!=ans[0]) others.push_back(c);
while(ans.size()+1 < N){
string q = ans + others[0] + ans + others[1] + others[0] + ans + others[1] + others[1] + ans + others[1] + others[2];
int len = ans.size();
r = press(q);
if (r == len) ans += others[2];
else if (r == len + 1) ans += others[0];
else ans += others[1];
}
if(press(ans+others[0]) == N) ans += others[0];
else if(press(ans+others[1]) == N) ans += others[1];
else ans += others[2];
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |