#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,t,k;
double p;
string ans;
int ask(int l,int r){
if(l>r)return false;
string s(n,'0');
for(int i=l;i<=r;i++)s[i]='1';
cout << "Q " << s << endl;
char res;
cin >> res;
return res=='P';
}
int solve(int l,int r){
while(l<r){
int m=(l+r)/2;
if(ask(l,m))r=m;
else l=m+1;
}
ans[l]=1;
return l;
}
void runcase(){
ans=string(n,'0');
for(int l=0,r=k-1;l<n;l+=k,r+=k){
r=min(r,n-1);
int x=l;
while(ask(x,r))x=solve(x,r)+1;
}
cout << "A " << ans << endl;
string s;
cin >> s;
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> p >> t;
double q=1-p,r=q;
k=1;
while(r>0.5&&k<n){
r*=q;
k++;
}
while(t--)runcase();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
344 KB |
Protocol violation |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |