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>
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
#include "combo.h"
string guess_sequence(int n) {
string ans; vector<char>v;
int a=press("AB");
if(a>0){
int c=press("A");
if(c>0){
ans.push_back('A');
v.push_back('B');v.push_back('X');v.push_back('Y');
}
else{
ans.push_back('B');
v.push_back('A');v.push_back('X');v.push_back('Y');
}
}
else{
int c=press("X");
if(c>0){
ans.push_back('X');
v.push_back('A');v.push_back('B');v.push_back('Y');
}
else{
ans.push_back('Y');
v.push_back('A');v.push_back('B');v.push_back('X');
}
}
if(n==1){
return ans;
}
for(int i=1;i<n-1;i++){
string ask;
ask+=ans;
ask+=v[0];
ask+=ans;
ask+=v[1];ask+=v[0];
ask+=ans;
ask+=v[1];ask+=v[1];
ask+=ans;
ask+=v[1];ask+=v[2];
int val=press(ask);
if(val==i+2){
ans.push_back(v[1]);
}
else if(val==i+1){
ans.push_back(v[0]);
}
else{
ans.push_back(v[2]);
}
}
bool f=1;
for(int i=0;i<=1;i++){
string s=ans+v[i];
if(press(s)==n){
f=0;
ans=s;
break;
}
}
if(f){
ans=ans+v[2];
}
return ans;
}
/*
int press(string s){
cout<<s<<"\n";
int a; cin>>a;
return a;
}
int main(){
int n; cin>>n;
string ans; vector<char>v;
int a=press("AB");
if(a>0){
int c=press("A");
if(c>0){
ans.push_back('A');
v.push_back('B');v.push_back('X');v.push_back('Y');
}
else{
ans.push_back('B');
v.push_back('A');v.push_back('X');v.push_back('Y');
}
}
else{
int c=press("X");
if(c>0){
ans.push_back('X');
v.push_back('A');v.push_back('B');v.push_back('Y');
}
else{
ans.push_back('Y');
v.push_back('A');v.push_back('B');v.push_back('X');
}
}
if(n==1){
cout<<ans;
return 0;
}
for(int i=1;i<n-1;i++){
string ask;
ask+=ans;
ask+=v[0];
ask+=ans;
ask+=v[1];ask+=v[0];
ask+=ans;
ask+=v[1];ask+=v[1];
ask+=ans;
ask+=v[1];ask+=v[2];
int val=press(ask);
if(val==i+2){
ans.push_back(v[1]);
}
else if(val==i+1){
ans.push_back(v[0]);
}
else{
ans.push_back(v[2]);
}
//cout<<"! "<<ans<<"\n";
}
cout<<"! "<<ans<<"\n";
bool f=1;
for(int i=0;i<=1;i++){
string s=ans+v[i];
if(press(s)==n){
f=0;
ans=s;
break;
}
}
if(f){
ans=ans+v[2];
}
cout<<ans<<"\n";
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |