# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1185552 | eri16 | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#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);
}
string 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;
}