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 a[]={'A','B','X','Y'};
vector<char> vec;
char fix(string ret)
{
int sz=ret.size();
string s=ret;
s+=vec[0];
for(int i=0;i<3;i++){
s+=ret;
s+=vec[1];
s+=vec[i];
}
int c=press(s);
// cout<<c<<" "<<s<<endl;
if(c==sz){
return vec[2];
}
else if(c==sz+1){
return vec[0];
}
else{
return vec[1];
}
}
std::string guess_sequence(int N){
vec.clear();
char l;
string ret;
string s;
s="AB";
int c=press(s);
// cout<<c<<" "<<s<<endl;
if(c>=1){
s="A";
c=press(s);
// cout<<c<<" "<<s<<endl;
if(c>=1){
l='A';
}
else{
l='B';
}
}
else{
s="X";
c=press(s);
// cout<<c<<" "<<s<<endl;
if(c>=1){
l='X';
}
else{
l='Y';
}
}
for(int i=0;i<4;i++){
if(a[i]!=l){
vec.push_back(a[i]);
}
}
ret+=l;
if(N==1)return ret;
for(int i=1;i<N-1;i++){
ret+=fix(ret);
}
s=ret+"A";
s+=ret+"B";
c=press(s);
// cout<<c<<" "<<s<<endl;
if(c==N){
s=ret+"A";
c=press(s);
// cout<<c<<" "<<s<<endl;
if(c==N){
ret+="A";
}
else ret+="B";
}
else{
s=ret+"X";
c=press(s);
// cout<<c<<" "<<s<<endl;
if(c==N){
ret+="X";
}
else ret+="Y";
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |