#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
#define pb push_back
typedef long long ll;
ll n, t;
double p;
bool qry(string s){
cout<<"Q "<<s<<endl;
char re;
cin>>re;
if(re=='P') return true;
return false;
}
void ans(string s){
cout<<"A "<<s<<endl;
char re;
cin>>re;
}
void solve(){
vector<bool> v(n);
auto f=[&](ll tar){
string tep;
for(ll i=0;i<n;i++){
if(i<=tar && !v[i]){
tep+='1';
}
else{
tep+='0';
}
}
return qry(tep);
};
ll pre=-1;
while(pre<n-1){
ll lef=pre+1, rig=n-1;
ll good=-1;
while(lef<=rig){
ll mid=(lef+rig)/2;
if(f(mid)){
good=mid;
rig=mid-1;
}
else{
lef=mid+1;
}
}
if(good==-1) break;
v[good]=1;
pre=good;
}
string tep;
for(ll i=0;i<n;i++){
if(v[i]) tep+='1';
else tep+='0';
}
ans(tep);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>p>>t;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |