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;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
const ll INF = 1e9+7;
ll n;
char st;
string complete(string s){
//encher de st
while((ll)s.size()!=n){
s.push_back(st);
}
return s;
}
std::string guess_sequence(int N) {
n=N;
string p,p1="",p2="",p3="",p4="";
ll i,k;
if(press("A")==1){
st='A';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
for(i=1;i<n-1;i++){//cout<<i<<"\n";
p="";
p1[i]='B'; p1[i+1]='B';
p2[i]='B'; p2[i+1]='X';
p3[i]='B'; p3[i+1]='Y';
p4[i]='X'; p4[i+1]='A';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
//cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" ";
p=p1+p2+p3+p4;
k = press(p);//cout<<k<<endl;
if(k==i){
p1[i]='Y';
p2[i]='Y';
p3[i]='Y';
p4[i]='Y';
}else if(k==i+1){
p1[i]='X';
p2[i]='X';
p3[i]='X';
p4[i]='X';
}else{
p1[i]='B';
p2[i]='B';
p3[i]='B';
p4[i]='B';
}
}
if(n>1){
p1[n-1]='B';
if(press(p1)==n)return p1;
p1[n-1]='X';
if(press(p1)==n)return p1;
p1[n-1]='Y';
return p1;
}else{
p="A";
return p;
}
}else if(press("B")==1){
st='B';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
for(i=1;i<n-1;i++){//cout<<i<<"\n";
p="";
p1[i]='A'; p1[i+1]='A';
p2[i]='A'; p2[i+1]='X';
p3[i]='A'; p3[i+1]='Y';
p4[i]='X'; p4[i+1]='B';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
//cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" ";
p=p1+p2+p3+p4;
k = press(p);//cout<<k<<endl;
if(k==i){
p1[i]='Y';
p2[i]='Y';
p3[i]='Y';
p4[i]='Y';
}else if(k==i+1){
p1[i]='X';
p2[i]='X';
p3[i]='X';
p4[i]='X';
}else{
p1[i]='A';
p2[i]='A';
p3[i]='A';
p4[i]='A';
}
}
if(n>1){
p1[n-1]='A';
if(press(p1)==n)return p1;
p1[n-1]='X';
if(press(p1)==n)return p1;
p1[n-1]='Y';
return p1;
}else{
p="B";
return p;
}
}else if(press("X")==1){
st='X';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
for(i=1;i<n-1;i++){//cout<<i<<"\n";
p="";
p1[i]='B'; p1[i+1]='B';
p2[i]='B'; p2[i+1]='A';
p3[i]='B'; p3[i+1]='Y';
p4[i]='A'; p4[i+1]='X';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
//cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" ";
p=p1+p2+p3+p4;
k = press(p);//cout<<k<<endl;
if(k==i){
p1[i]='Y';
p2[i]='Y';
p3[i]='Y';
p4[i]='Y';
}else if(k==i+1){
p1[i]='A';
p2[i]='A';
p3[i]='A';
p4[i]='A';
}else{
p1[i]='B';
p2[i]='B';
p3[i]='B';
p4[i]='B';
}
}
if(n>1){
p1[n-1]='B';
if(press(p1)==n)return p1;
p1[n-1]='A';
if(press(p1)==n)return p1;
p1[n-1]='Y';
return p1;
}else{
p="X";
return p;
}
}else{
st='Y';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
for(i=1;i<n-1;i++){//cout<<i<<"\n";
p="";
p1[i]='B'; p1[i+1]='B';
p2[i]='B'; p2[i+1]='X';
p3[i]='B'; p3[i+1]='A';
p4[i]='X'; p4[i+1]='Y';
p1=complete(p1);
p2=complete(p2);
p3=complete(p3);
p4=complete(p4);
//cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" ";
p=p1+p2+p3+p4;
k = press(p);//cout<<k<<endl;
if(k==i){
p1[i]='A';
p2[i]='A';
p3[i]='A';
p4[i]='A';
}else if(k==i+1){
p1[i]='X';
p2[i]='X';
p3[i]='X';
p4[i]='X';
}else{
p1[i]='B';
p2[i]='B';
p3[i]='B';
p4[i]='B';
}
}
if(n>1){
p1[n-1]='B';
if(press(p1)==n)return p1;
p1[n-1]='X';
if(press(p1)==n)return p1;
p1[n-1]='A';
return p1;
}else{
p="Y";
return p;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |