Submission #1042076

#TimeUsernameProblemLanguageResultExecution timeMemory
1042076WarinchaiCOVID tests (CEOI24_covid)C++14
95.55 / 100
1380 ms1844 KiB
#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=0; if(cur+(1<<mx)>=n){ while(cur+(1<<nmx)<n)nmx++; nmx--; }else{ 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<<"overflow"<<endl; int nw=nmx+1; while(cur+(1<<nw)<n&&ask(cur+1,cur+(1<<nw))==0){ nw++; } //cout<<"end"<<nw<<endl; if(cur+(1<<nw)>=n){ //cout<<"still ov"<<cur<<" "<<n<<endl; if(!ask(cur+1,n-1))break; //cout<<"what"<<endl; int ogcur=cur; for(int i=nw-1;i>=0;i--)if(!ask(ogcur+1,cur+(1<<i)))cur=cur+(1<<i); cur++; ans[cur]='1'; }else{ //cout<<"not ov"<<endl; int ogcur=cur; for(int i=nw-1;i>=0;i--)if(!ask(ogcur+1,cur+(1<<i)))cur=cur+(1<<i); cur++; ans[cur]='1'; } } } //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; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...