Submission #1038744

#TimeUsernameProblemLanguageResultExecution timeMemory
1038744WarinchaiCOVID tests (CEOI24_covid)C++14
52.27 / 100
1695 ms600 KiB
#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); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>p>>t; temp=string(n,'0'); int prob=max(1,(int)p*n); prob=min(n,prob); int div=n/prob; int val=0; for(;val<=10;val++){ if((1<<val)>div)break; } val--; div=(1<<val); //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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...