Submission #1044240

#TimeUsernameProblemLanguageResultExecution timeMemory
1044240gagik_2007COVID tests (CEOI24_covid)C++17
80.61 / 100
7054 ms2344 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=5007; ll n,m,k; double p; map<string, int>d; int DIV=100; bool query(string s){ if(d[s]){ if(d[s]==1){ return false; } return true; } cout<<"Q "<<s<<endl; char res; cin>>res; bool ress=false; if(res=='P'){ ress=true; } d[s]=ress+1; return ress; } bool queryRange(int l, int r){ string s=""; for(int i=0;i<l;i++){ s+='0'; } for(int i=l;i<=r;i++){ s+='1'; } for(int i=r+1;i<n;i++){ s+='0'; } return query(s); } int findNextPositive(int from, int to){ if(!queryRange(from, to)){ return to+1; } int l=from; int r=to; while(l<r){ int mid=(l+r)/2; if(queryRange(l, mid)){ r=mid; } else{ l=mid+1; } } return l; } void clear(){ d.clear(); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("Binput.txt","r",stdin); // freopen("Boutput.txt","w",stdout); cin>>n>>p>>ttt; if(p<0.005){ DIV=1; } else if(p<0.02){ DIV=10; } else if(p<0.03){ DIV=33; } else if(p<0.05){ DIV=50; } else if(p<0.1){ DIV=90; } else if(p<0.15){ DIV=125; } else if(p<0.18){ DIV=250; } else{ DIV=350; } while(ttt--){ clear(); string ans=""; for(int i=0;i<n;i++){ ans+='0'; } for(int fromm=0;fromm<n;fromm+=n/DIV){ int from=fromm; int to=min(from+n/DIV-1,n-1); while(true){ int ind=findNextPositive(from,to); if(ind==to+1){ break; } from=ind+1; ans[ind]='1'; if(from>=to+1)break; } } cout<<"A "<<ans<<endl; char c; cin>>c; if(c=='W'){ return 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...