#include "combo.h"
using namespace std;
string solve(string x,string y,string z, string k,int N){
int sz=k.size();
if (sz!=N-1){
string temp=k+x+x+k+x+y+k+x+z+k+y;
if (press(temp)==sz){
k+=z;
}
if (press(temp)==sz+1){
k+=y;
}
if (press(temp)==sz+2){
k+=x;
}
return solve(x,y,z,k,N);
}
if (sz==N-1){
string temp=k+x;
if (press(temp)==N){
return (temp);
}
temp=k+y;
if (press(temp)==N){
return (temp);
}
else{
return (k+z);
}
}
}
string guess_sequence(int N) {
string p = "";
string check = "";
string ans;
check += "ab";
if (press(check)>=1){
check.clear();
check+="a";
if (press(check)==1){
ans=solve ("x","y","b","a",N);
}
if (press(check)==0){
ans=solve ("x","y","a","b",N);
}
}
if (press(check)==0){
check.clear();
check+="x";
if (press(check)==1){
ans=solve ("b","y","a","x",N);
}
if (press(check)==0){
ans=solve ("x","b","a","y",N);
}
}
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string solve(std::string, std::string, std::string, std::string, int)':
combo.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
48 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |