#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int n){
string p = "";
set<string> S;
S.insert("A");
S.insert("B");
S.insert("X");
S.insert("Y");
string trash = "AB";
int c = press(trash);
if(c>=1){
c = press("A");
if(c==1)p+="A";
else p+="B";
}
else{
c = press("X");
if(c==1)p+="X";
else p+="Y";
}
if(n==1)return p;
S.erase(p);
// Remaining letters up to the (n-1)th
int cc=0;
string b,xx,y;
for (auto x: S){
if (cc == 0) b = x;
if (cc == 1) xx = x;
if (cc == 2) y = x;
cc++;
}
int count = 1;
for(int i=0; i<n-2; i++){
string t = p+b+p+xx+y+p+xx+xx+p+xx+b;
c = press(t);
if(c==count)p+=y;
else if(c==count+1)p+=b;
else p+=xx;
count++;
}
c = press(p+xx);
if(c==n)
p+=xx;
else{
c = press(p+b);
if(c==n)p+=b;
else p+=y;
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |