#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;l<n;){
int r=min(l+k-1,n-1);
if(ask(l,r)){
l=solve(l,r)+1;
}else{
l+=k;
}
}
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;
double cut=0.57;
if(p==0.2)cut=0.5;
if(p==0.104571)cut=0.46;
k=1;
while(r>cut&&k<n){
r*=q;
k++;
}
while(t--)runcase();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
5 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 |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
9 |
Correct |
4 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
344 KB |
Output is correct |
13 |
Correct |
4 ms |
344 KB |
Output is correct |
14 |
Correct |
4 ms |
344 KB |
Output is correct |
15 |
Correct |
5 ms |
344 KB |
Output is correct |
16 |
Correct |
4 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=10.9) -> 90.00 points |
2 |
Correct |
82 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=47.0) -> 90.00 points |
3 |
Correct |
169 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=91.9) -> 90.00 points |
4 |
Correct |
338 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=190.6) -> 90.00 points |
5 |
Correct |
466 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=247.3) -> 88.56 points |
6 |
Correct |
694 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=365.8) -> 90.00 points |
7 |
Correct |
889 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=493.5) -> 87.71 points |
8 |
Correct |
1051 ms |
344 KB |
Output is correct (P=0.158765, F=639.1, Q=633.1) -> 90.00 points |
9 |
Correct |
1296 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=740.9) -> 85.55 points |