#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
string s;
if(press("AB")){
if(press("A"))s="A";
else s="B";
}else{
if(press("X"))s="X";
else s="Y";
}
vector<char>m;
string temp="ABXY";
for(int i=0;i<4;i++)if(temp[i]!=s[0])m.push_back(temp[i]);
int sz=1;
while(sz<n-1){
string q;
q.append(s);
q.push_back(m[0]);
q.push_back(m[0]);
q.append(s);
q.push_back(m[0]);
q.push_back(m[1]);
q.append(s);
q.push_back(m[0]);
q.push_back(m[2]);
q.append(s);
q.push_back(m[1]);
int num=press(q);
if(num==sz+2){
s.push_back(m[0]);
}else if(num==sz+1){
s.push_back(m[1]);
}else{
s.push_back(m[2]);
}
sz++;
}
string q;
q.append(s);
q.push_back(m[0]);
int num=press(q);
if(num==n)s.push_back(m[0]);
else{
q.pop_back();
q.push_back(m[1]);
num=press(q);
if(num==n)s.push_back(m[1]);
else s.push_back(m[2]);
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |