#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N){
string ans = "";
vector<char>possible = {'A','B','X','Y'};
vector<char>npossible = {'A','B','X','Y'};
for(int i=0;i<N;i++){
if(i==N-1){
string q = "";
q+=ans+npossible[0];
q+=ans+npossible[1];
int tmp = press(q);
if(tmp==N){
q=ans+npossible[0];
tmp = press(q);
if(tmp==N)ans+=npossible[0];
else ans+=npossible[1];
}else{
if(npossible.size()==3)ans+=npossible[2];
else{
q=ans+npossible[2];
tmp = press(q);
if(tmp==N)ans+=npossible[2];
else ans+=npossible[3];
}
}
}else if(i==0){
string q = "";
q+=(possible[0]);
q+=(possible[1]);
int tmp = press(q);
if(tmp==1){
q = possible[0];
tmp = press(q);
if(tmp==1)ans+=possible[0];
else ans+=possible[1];
}else{
q = possible[2];
tmp = press(q);
if(tmp==1)ans+=possible[2];
else ans+=possible[3];
}npossible.clear();
for(int j=0;j<4;j++){
if(possible[j]!=ans[0])npossible.push_back(possible[j]);
}
}else{
string q = "";
q+=ans+npossible[0];
for(int j=0;j<3;j++){
q+=ans+npossible[1]+npossible[j];
}int tmp = press(q);
if(tmp==i+1){
ans+=npossible[0];
}else if(tmp==i+2){
ans+=npossible[1];
}else{
ans+=npossible[2];
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |