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>
using namespace std;
int n,t;
double p;
int use=0;
int ask(vector<int>v){
//use++;
cout<<"Q ";
for(auto x:v)cout<<x;
cout<<endl;
//cerr<<"input:"<<endl;
char ans;
cin>>ans;
//cerr<<ans<<endl;
return ans=='P'?1:0;
}
vector<int> fans(int st,int en){
//cerr<<st<<" "<<en<<endl;
if(st>=en)return {};
int m=(st+en)/2;
vector<int>temp(n,0);
for(int i=st;i<=m;i++)temp[i]=1;
vector<int>l,r;
if(ask(temp)){
if(st==m)l={1};
else l=fans(st,m);
}else l=vector<int>(m-st+1,0);
for(int i=st;i<=m;i++)temp[i]=0;
for(int i=m+1;i<=en;i++)temp[i]=1;
if(ask(temp)){
if(m+1==en)r={1};
else r=fans(m+1,en);
}else r=vector<int>(en-m,0);
vector<int>ans;
for(auto x:l)ans.push_back(x);
for(auto x:r)ans.push_back(x);
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>p>>t;
while(t--){
//cerr<<"work"<<endl;
use=0;
vector<int>ans=fans(0,n-1);
cout<<"A ";
for(auto x:ans)cout<<x;
cout<<endl;
char res;
cin>>res;
//cerr<<"use:"<<use<<endl;
if(res=='W')break;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |