#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);
freq=min(n,freq);
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;
int rmx=freq;
//cout<<nmx<<endl;
if(ask(og+1,cur+freq)){
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+freq;
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;
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:47:17: warning: unused variable 'rmx' [-Wunused-variable]
47 | int rmx=freq;
| ^~~
# |
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 |
6 ms |
1368 KB |
Output is correct |
2 |
Correct |
5 ms |
1328 KB |
Output is correct |
3 |
Correct |
7 ms |
1440 KB |
Output is correct |
4 |
Correct |
5 ms |
1368 KB |
Output is correct |
5 |
Correct |
5 ms |
1520 KB |
Output is correct |
6 |
Correct |
6 ms |
1456 KB |
Output is correct |
7 |
Correct |
7 ms |
1368 KB |
Output is correct |
8 |
Incorrect |
4 ms |
1112 KB |
translate:wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
translate:wrong |
2 |
Halted |
0 ms |
0 KB |
- |