# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372935 | mariowong | 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"
std::string guess_sequence(int N) {
string p,S;
char f,s,t;
if (press("AB") >= 1){
if (press("A") == 1)
S+='A';
else
S+='B';
}
else
{
if (press("X") == 1)
S+='X';
else
S+='Y';
}
for (int i = 2; i < N; i++){
p.clear();
if (S[0] == 'A'){
p+=S; p+='B';
p+=S; p+='X'; p+='X';
p+=S; p+='X'; p+='Y';
p+=S; p+='X'; p+='B';
f='B'; s='X'; t='Y';
}
if (S[0] == 'B'){
p+=S; p+='A';
p+=S; p+='X'; p+='X';
p+=S; p+='X'; p+='Y';
p+=S; p+='X'; p+='A';
f='A'; s='X'; t='Y';
}
if (S[0] == 'X'){
p+=S; p+='A';
p+=S; p+='B'; p+='B';
p+=S; p+='B'; p+='Y';
p+=S; p+='B'; p+='A';
f='A'; s='B'; t='Y';
}
if (S[0] == 'Y'){
p+=S; p+='A';
p+=S; p+='B'; p+='B';
p+=S; p+='B'; p+='X';
p+=S; p+='B'; p+='A';
f='A'; s='B'; t='X';
}
int ct=press(p);
if (ct == i)
S+=f;
else
if (ct == i-1)
S+=t;
else
S+=s;
}
if (S[0] == 'A'){
p=S+'B';
if (press(p) == N)
return p;
p=S+'X';
if (press(p) == N)
return p;
p=S+'Y';
return p;
}
if (S[0] == 'B'){
p=S+'A';
if (press(p) == N)
return p;
p=S+'X';
if (press(p) == N)
return p;
p=S+'Y';
return p;
}
if (S[0] == 'X'){
p=S+'A';
if (press(p) == N)
return p;
p=S+'B';
if (press(p) == N)
return p;
p=S+'Y';
return p;
}
if (S[0] == 'Y'){
p=S+'B';
if (press(p) == N)
return p;
p=S+'X';
if (press(p) == N)
return p;
p=S+'A';
return p;
}
}