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<bits/stdc++.h>
#include"combo.h"
using namespace std;
std::string guess_sequence(int N) {
long long n=N,x;
string str="",temp;
string ch[]={"A","B","X","Y"};
vector<string>posi={};
if(n==1){
for(auto i:ch){
if(i==ch[3]) return i;
x=press(i);
if(x==1) return i;
}
}
x=press("AB");
if(x){
x=press("A");
if(x) str="A";
else str="B";
}else{
x=press("X");
if(x) str="X";
else str="Y";
}
for(auto i:ch) if(i[0]!=str[0]) posi.push_back(i);
for(int i=1;i<n-1;i++){
temp="";
for(auto i:posi){
temp+=str+posi[0]+i;
}
temp+=posi[1];
x=press(temp);
if(x==i) str+=posi[2];
else if(x==i+1) str+=posi[1];
else str+=posi[0];
}
for(auto i:posi){
if(i==posi[2]){
str+=i;
break;
}
x=press(str+i);
if(x==n){
str+=i;
break;
}
}
return str;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |