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 <iostream>
std::string guess_sequence(int N) {
char keys[4]={'A','B','X','Y'};
int first=-1;
if(press("AB")>0){
if(press("A")>0){
first=0;
}else{
first=1;
}
}else{
if(press("X")>0){
first=2;
}else{
first=3;
}
}
std::string str(1,keys[first]);
if(N==1) return str;
for(int i=1;i<N-1;++i) {
int score=press(str+keys[first^2]+
str+keys[first^3]+keys[first^1]+
str+keys[first^3]+keys[first^2]+
str+keys[first^3]+keys[first^3])-i;
switch(score){
case 0:str+=keys[first^1];break;
case 1:str+=keys[first^2];break;
case 2:str+=keys[first^3];break;
}
}
if(press(str+keys[first^1])==N){
return str+keys[first^1];
}
if(press(str+keys[first^2])==N){
return str+keys[first^2];
}
return str+keys[first^3];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |