Submission #615808

#TimeUsernameProblemLanguageResultExecution timeMemory
615808Koosha_mvCounting Mushrooms (IOI20_mushrooms)C++14
0 / 100
2 ms336 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int S=187,N=20202; mt19937 rng(time(nullptr)); int n,ans,mark[N]; vector<int> A,B; int get(vector<int> vec){ if(vec.size()<=A.size()){ vector<int> res; f(i,0,int(vec.size())) res.pb(vec[i]),res.pb(A[i]); int prt=(use_machine(res)+1)/2; if(prt&1) B.pb(vec[0]); else A.pb(vec[0]); return int(vec.size())-prt; } else{ vector<int> res; f(i,0,int(vec.size())) res.pb(vec[i]),res.pb(B[i]); int prt=(use_machine(res)+1)/2; if(prt&1) A.pb(vec[0]); else B.pb(vec[0]); return prt; } } int count_mushrooms(int _n) { n=_n; A.pb(0); vector<int> p(n-1); iota(all(p),1); shuffle(all(p),rng); f(i,0,min(n-1,S-1)){ vector<int> vec; vec.pb(0); vec.pb(p[i]); mark[p[i]]=1; //dbgv(vec); if(use_machine(vec)==0){ A.pb(p[i]); } else{ B.pb(p[i]); } } vector<int> vec; f(i,1,n){ if(mark[i]) continue ; vec.pb(i); if(int(vec.size())>=max(int(A.size()),int(B.size()))){ ans+=get(vec); vec.clear(); } } if(vec.size()) ans+=get(vec); return ans+A.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...