This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
bool ans[1000];
string question;
int N;
bool ask(int inf, int sup, bool preg){
cin.tie(nullptr);
ios::sync_with_stdio(0);
char c='P';
if(preg){
cout<<"Q ";
for(int i=inf; i<=sup; i++){
question[i]='1';
}
cout<<question<<endl;
for(int i=inf; i<=sup; i++){
question[i]='0';
}
cout.flush();
cin>>c;
}
if(c=='N'){
for(int i=inf; i<=sup; i++) ans[i]=false;
return false;
}else if(inf==sup){
ans[inf]=true;
return true;
}else{
int m = (inf+sup)/2;
ask(m+1, sup, ask(inf, m, true));
return true;
}
}
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(0);
int T;
double P;
cin>>N>>P>>T;
double jaskier=0.6;
for(int i=0; i<1000; i++) question.push_back('0');
for(int dalekofrivia=0; dalekofrivia<T; dalekofrivia++){
if(P<0.001) P=0.001;
int u=0.5+log(jaskier/P)/log(2);
int lambda=1;
for(int i=0; i<u; i++) lambda*=2;
for(int i=0; i<N; i++) question[i]='0';
for(int i=0; i<N; i=i+lambda) ask(i, min(i+lambda, N)-1, true);
cout<<"A ";
for(int i=0; i<N; i++) cout<<ans[i];
cout<<endl;
cout.flush();
char C;
cin>>C;
if(C!='C') break;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |