#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
int n,t;
double p;
int use=0;
map<string,int>mp;
int ask(string v){
if(mp[v]!=0)return mp[v]-1;
//use++;
cout<<"Q ";
cout<<v;
cout<<endl;
//cerr<<"input:"<<endl;
char ans;
cin>>ans;
//cerr<<ans<<endl;
return (mp[v]=(ans=='P'?1:0)+1)-1;
}
int ask(int st,int en){
en=min(n-1,en);
string temp(n,'0');
for(int i=st;i<=en;i++)temp[i]='1';
return ask(temp);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>p>>t;
int freq=n/(p*n);
int mx=0;
while((1<<mx)<freq)mx++;
mx--;
mx=min(9,mx);
mx=max(0,mx);
while(t--){
//cerr<<"work"<<endl;
mp.clear();
int cur=-1;
string ans=string(n,'0');
int og=cur;
while(cur<n-1){
int nmx=mx;
//cout<<nmx<<endl;
if(ask(og+1,cur+(1<<nmx))){
for(int i=nmx-1;i>=0;i--)if(!ask(og+1,cur+(1<<i)))cur=cur+(1<<i);
cur++;
ans[cur]='1';
og=cur;
}else{
cur=cur+(1<<nmx);
continue;
}
}
//cout<<x<<endl;
//cout<<ask(x)<<endl;
//assert(ask(x)==0);
cout<<"A ";
cout<<ans;
cout<<endl;
char res;
cin>>res;
//cerr<<"use:"<<use<<endl;
if(res=='W')break;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1680 KB |
Output is correct |
2 |
Correct |
6 ms |
1348 KB |
Output is correct |
3 |
Correct |
8 ms |
1344 KB |
Output is correct |
4 |
Correct |
5 ms |
1368 KB |
Output is correct |
5 |
Correct |
5 ms |
1416 KB |
Output is correct |
6 |
Correct |
7 ms |
1440 KB |
Output is correct |
7 |
Correct |
7 ms |
1684 KB |
Output is correct |
8 |
Correct |
6 ms |
1368 KB |
Output is correct |
9 |
Correct |
5 ms |
1504 KB |
Output is correct |
10 |
Correct |
4 ms |
1112 KB |
Output is correct |
11 |
Correct |
6 ms |
1416 KB |
Output is correct |
12 |
Correct |
7 ms |
1368 KB |
Output is correct |
13 |
Correct |
5 ms |
1368 KB |
Output is correct |
14 |
Correct |
6 ms |
1500 KB |
Output is correct |
15 |
Correct |
6 ms |
1624 KB |
Output is correct |
16 |
Correct |
7 ms |
1336 KB |
Output is correct |
17 |
Correct |
6 ms |
1368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=10.9) -> 90.00 points |
2 |
Correct |
93 ms |
596 KB |
Output is correct (P=0.005256, F=51.1, Q=46.6) -> 90.00 points |
3 |
Correct |
173 ms |
816 KB |
Output is correct (P=0.011546, F=94.9, Q=90.9) -> 90.00 points |
4 |
Correct |
376 ms |
1136 KB |
Output is correct (P=0.028545, F=191.5, Q=189.6) -> 90.00 points |
5 |
Correct |
448 ms |
1268 KB |
Output is correct (P=0.039856, F=246.3, Q=244.0) -> 90.00 points |
6 |
Correct |
739 ms |
1312 KB |
Output is correct (P=0.068648, F=366.2, Q=365.8) -> 90.00 points |
7 |
Correct |
965 ms |
1480 KB |
Output is correct (P=0.104571, F=490.3, Q=493.5) -> 87.71 points |
8 |
Correct |
1190 ms |
1420 KB |
Output is correct (P=0.158765, F=639.1, Q=633.1) -> 90.00 points |
9 |
Correct |
1424 ms |
1760 KB |
Output is correct (P=0.2, F=731.4, Q=740.9) -> 85.55 points |