Submission #825548

#TimeUsernameProblemLanguageResultExecution timeMemory
825548Edu175Counting Mushrooms (IOI20_mushrooms)C++17
0 / 100
19 ms352 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define pb push_back #define fst first #define snd second #define fore(i,a,b) for(ll i=a,ioi=b;i<ioi;i++) #define SZ(x) ((int)x.size()) #define ALL(x) x.begin(),x.end() #define mset(a,v) memset((a),(v),sizeof(a)) #define imp(v) for(auto dfh:v)cout<<dfh<<" ";cout<<"\n" using namespace std; typedef long long ll; typedef pair<ll,ll> ii; const ll MAXN=2e4+5; ll ask(vector<ll>a){ vector<int>ai; for(auto i:a)ai.pb(i); return use_machine(ai); } map<ii,ll>did; ll ran(ll l, ll r){ //[,] if(did.count({l,r}))return did[{l,r}]; ll &res=did[{l,r}]; if(l==r)return res=0; vector<ll>a; fore(i,l,r+1)a.pb(i); return res=ask(a); } int count_mushrooms(int n){ ll res=0; ll p=0,k=ran(0,n-1)+1; ll c=0; while(k>1){ //cout<<p<<" "<<k<<" "<<c<<": "; ll l=p,r=n-k,s=p; while(l<=r){ ll m=(l+r)/2; if(ran(s,m)==0)l=m+1,s=m; else r=m-1; } if(!c)res+=l-p; //cout<<l<<"\n"; p=l; c^=1; k--; } if(!c)res+=n-p; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...