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 <string>
#include <algorithm>
using namespace std;
int f;
int t(int x){
return x%4;
}
string base = "ABXY";
string str="";
string q;
string guess_sequence(int N) {
if(press("AB")!=0){
if(press("A")!=0){
f=0; str+="A";
}else{
f=1; str+="B";
}
}else{
if(press("X")!=0){
f=2; str+="X";
}else{
f=3; str+="Y";
}
}
if(N==1){
return str;
}
for(int i=1; i<N-1; i++){
q.clear();
q+=(str+base[t(f+1)]);
q+=(str+base[t(f+2)]+base[t(f+1)]);
q+=(str+base[t(f+2)]+base[t(f+2)]);
q+=(str+base[t(f+2)]+base[t(f+3)]);
int query = press(q);
if(query == i){
str+=base[t(f+3)];
}else if(query == i+1){
str+=base[t(f+1)];
}else{
str+=base[t(f+2)];
}
}
if(press(str+base[t(f+1)])==N){
return str+base[t(f+1)];
}else if(press(str+base[t(f+2)])==N){
return str+base[t(f+2)];
}return str+base[t(f+3)];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |