Submission #615823

#TimeUsernameProblemLanguageResultExecution timeMemory
615823Koosha_mvCounting Mushrooms (IOI20_mushrooms)C++14
67.06 / 100
11 ms448 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; int n,ans; 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); if(prt&1) B.pb(vec[0]); else A.pb(vec[0]); prt=(prt+1)/2; 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); if(prt&1) A.pb(vec[0]); else B.pb(vec[0]); prt=(prt+1)/2; return prt; } } int count_mushrooms(int _n) { n=_n; A.pb(0); f(i,1,min(n,S)){ vector<int> vec; vec.pb(0); vec.pb(i); if(use_machine(vec)==0){ A.pb(i); } else{ B.pb(i); } } ans=A.size(); vector<int> vec; f(i,S,n){ vec.pb(i); if(i==n-1 || int(vec.size())>=max(int(A.size()),int(B.size()))){ ans+=get(vec); vec.clear(); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...