# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1129910 | pedreitorzelda | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
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]+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==1){
ans+=npossible[0];
}else if(tmp==2){
ans+=npossible[1];
}else{
ans+=npossible[2];
}
}
}
return ans;
}