#include "bits/stdc++.h"
//#define int long long
//#define double long double
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
mt19937 rng(time(nullptr));
bool test_students(vector<bool> mask){
cout << "Q ";
for(int x:mask) cout << x;
cout << '\n' << flush;
char answer; cin >> answer;
return answer == 'P';
}
int BL,n,tc=1;
double p;
vector<bool> cur,A;
vector<int> ar,Store;
double fast_pow(double x,int b){
if(b==0) return 1.0;
double res = fast_pow(x,b/2);
res*=res;
if(b&1) res*=x;
return res;
}
void update_block(){
int l=1,r=n;
while(l<r){
int mid=(l+r+1)/2;
if(fast_pow(p,mid)>=0.5) l=mid;
else r=mid-1;
}
Store.resize(n+5);
for(int i=1;i<=n;i++) Store[i]=min(i,l);
}
bool ask_range(int l,int r){
for(int i=l;i<=r;i++) cur[ar[i]]=1;
bool res = test_students(cur);
for(int i=l;i<=r;i++) cur[ar[i]]=0;
}
int find_first(int l,int r){
if(l==r) return l;
int m=(l+r)/2;
if(ask_range(l,m)) return find_first(l,m);
return find_first(m+1,r);
}
vector<bool> find_positive(){
for(int i=0;i<n;){
BL=Store[n-i];
if(!ask_range(i,i+BL-1)){
i+=BL;
continue;
}
int lmao = find_first(i,i+BL-1);
A[ar[lmao]]=1;
i=lmao+1;
}
return A;
}
void _(){
A.assign(n,0);
vector<bool> GG = find_positive();
cout << "A ";
for(bool x:GG) cout << x;
cout << '\n' << flush;
char son; cin >> son;
if(son=='C') return;
else exit(0);
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
cin >> n >> p >> tc;
p=1.0-p;
update_block();
ar.assign(n,0);
iota(all(ar),0LL);
shuffle(all(ar),rng);
while(tc--) _();
return 0;
}
Compilation message
Main.cpp: In function 'bool ask_range(int, int)':
Main.cpp:45:8: warning: unused variable 'res' [-Wunused-variable]
45 | bool res = test_students(cur);
| ^~~
Main.cpp:47:1: warning: no return statement in function returning non-void [-Wreturn-type]
47 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |