#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
int n,t;
double p;
int use=0;
int ask(string v){
//use++;
cout<<"Q ";
cout<<v;
cout<<endl;
//cerr<<"input:"<<endl;
char ans;
cin>>ans;
//cerr<<ans<<endl;
return ans=='P'?1:0;
}
string temp;
string ans;
void fans(int st,int en){
//cerr<<st<<" "<<en<<endl;
if(st==en){
temp[st]='1';
ans[st]=ask(temp)?'1':'0';
temp[st]='0';
return;
}
if(st>en)return;
int m=(st+en)/2;
for(int i=st;i<=m;i++)temp[i]='1';
bool tans;tans=ask(temp);
for(int i=st;i<=m;i++)temp[i]='0';
if(tans){
if(st==m)ans[st]='1';
else fans(st,m);
for(int i=m+1;i<=en;i++)temp[i]='1';
tans=ask(temp);
for(int i=m+1;i<=en;i++)temp[i]='0';
if(tans){
if(m+1==en)ans[en]='1';
else fans(m+1,en);
}
}else{
if(m+1==en)ans[en]='1';
else fans(m+1,en);
}
}
double pp[9]={0.001,0.005256,0.011546,0.028545,0.039856,0.068648,0.104571,0.158765,0.2};
double ep=0.0001;
//int mx[9]={15,51,94,191,246,366,490,639,731};
//int mx[9]={5,10,94,191,246,366,490,639,731};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>p>>t;
temp=string(n,'0');
int cur=-1;
for(int i=0;i<9;i++)if(abs(pp[cur]-p)<ep)cur=i;
int prob=0;
prob=max(1,(int)(1000*p*1.5));
prob=min(n,prob);
int div=n/prob;
//cerr<<"prob:"<<prob<<endl;
//cerr<<"div:"<<div<<endl;
while(t--){
//cerr<<"work"<<endl;
ans=string(n,'0');
use=0;
for(int i=1;i<prob;i++){
cerr<<"prob-"<<i<<endl;
string t(n,'0');
for(int j=div*(i-1);j<=div*i-1;j++)t[j]='1';
if(div*i-1==div*(i-1)||ask(t))fans(div*(i-1),div*i-1);
for(int j=div*(i-1);j<=div*i-1;j++)t[j]='0';
}
string temp(n,'0');
for(int j=div*(prob-1);j<=n-1;j++)temp[j]='1';
if(div*(prob-1)==n-1||ask(temp))fans(div*(prob-1),n-1);
cout<<"A ";
cout<<ans;
cout<<endl;
char res;
cin>>res;
//cerr<<"use:"<<use<<endl;
if(res=='W')break;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
340 KB |
Output is correct |
2 |
Correct |
9 ms |
340 KB |
Output is correct |
3 |
Correct |
8 ms |
344 KB |
Output is correct |
4 |
Correct |
8 ms |
600 KB |
Output is correct |
5 |
Correct |
9 ms |
716 KB |
Output is correct |
6 |
Correct |
11 ms |
504 KB |
Output is correct |
7 |
Correct |
10 ms |
460 KB |
Output is correct |
8 |
Correct |
7 ms |
344 KB |
Output is correct |
9 |
Correct |
8 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
8 ms |
344 KB |
Output is correct |
12 |
Correct |
7 ms |
344 KB |
Output is correct |
13 |
Correct |
10 ms |
344 KB |
Output is correct |
14 |
Correct |
8 ms |
344 KB |
Output is correct |
15 |
Correct |
7 ms |
600 KB |
Output is correct |
16 |
Correct |
12 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=13.9) -> 90.00 points |
2 |
Correct |
123 ms |
444 KB |
Output is correct (P=0.005256, F=51.1, Q=59.1) -> 55.34 points |
3 |
Correct |
231 ms |
592 KB |
Output is correct (P=0.011546, F=94.9, Q=111.7) -> 52.69 points |
4 |
Correct |
493 ms |
1028 KB |
Output is correct (P=0.028545, F=191.5, Q=228.1) -> 51.01 points |
5 |
Correct |
603 ms |
992 KB |
Output is correct (P=0.039856, F=246.3, Q=282.4) -> 56.74 points |
6 |
Correct |
929 ms |
1180 KB |
Output is correct (P=0.068648, F=366.2, Q=425.2) -> 54.73 points |
7 |
Correct |
1132 ms |
1788 KB |
Output is correct (P=0.104571, F=490.3, Q=561.2) -> 57.02 points |
8 |
Correct |
1534 ms |
1408 KB |
Output is correct (P=0.158765, F=639.1, Q=678.3) -> 72.27 points |
9 |
Correct |
1759 ms |
1452 KB |
Output is correct (P=0.2, F=731.4, Q=821.2) -> 60.36 points |