# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333576 | nicholask | Combo (IOI18_combo) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
char c[4]={'A','B','X','Y'};
string guess_sequence(int n){
string ans="";
for (int i=1; i<=n; i++){
int fc;
if (i==1){
if (press("AB")){;
if (press("A")){
ans+='A';
fc=0;
} else {
ans+='B';
fc=1;
}
} else {
if (press("X")){
ans+='X';
fc=2;
} else {
ans+='Y';
fc=3;
}
}
continue;
}
if (i==n){
string q=ans;
q+=c[(fc+1)%4];
if (press(q)==n) ans+=c[(fc+1)%4];
else {
q.pop_back();
q+=c[(fc+2)%4];
if (press(q)==n) ans+=c[(fc+2)%4];
else ans+=c[(fc+3)%4];
}
continue;
}
string q="";
q+=ans;
q+=c[(fc+1)%4];
q+=c[(fc+1)%4];
q+=ans;
q+=c[(fc+1)%4];
q+=c[(fc+2)%4];
q+=ans;
q+=c[(fc+1)%4];
q+=c[(fc+3)%4];
q+=ans;
q+=c[(fc+2)%4];
int c=press(q);
if (c==ans.size()+2) ans+=c[(fc+1)%4];
else if (c==ans.size()+1) ans+=c[(fc+2)%4];
else ans+=c[(fc+3)%4];
}
return ans;
}