#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){
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';
}
void solve(int l,int r){
if(l==r)return void(ans[l]='1');
int m=(l+r)/2;
bool found=false;
if(rng()&1){
if(ask(l,m)){
solve(l,m);
found=true;
}
if(!found&&ask(m+1,r)){
solve(m+1,r);
}
}else{
if(ask(m+1,r)){
solve(m+1,r);
found=true;
}
if(!found&&ask(l,m)){
solve(l,m);
}
}
}
void runcase(){
ans=string(n,'0');
for(int l=0,r=k-1;l<n;l+=k,r+=k){
r=min(r,n-1);
if(ask(l,r))solve(l,r);
}
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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
translate:wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
8 |
Incorrect |
4 ms |
344 KB |
translate:wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |