Submission #830229

#TimeUsernameProblemLanguageResultExecution timeMemory
830229Edu175Counting Mushrooms (IOI20_mushrooms)C++17
56.08 / 100
8 ms432 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); } const ll B=120; int count_mushrooms(int N){ ll n=N; vector<ll>a[2]; a[0]={0}; ll w=2,p=n; fore(i,1,n){ if(SZ(a[0])==B){ w=0; p=i; break; } if(SZ(a[1])==B){ w=1; p=i; break; } if(ask({0,i}))a[1].pb(i); else a[0].pb(i); } ll res=SZ(a[0]); for(ll i=p;i<n;i+=SZ(a[w])){ vector<ll>v; ll k=0; fore(j,i,min(n,i+SZ(a[w]))){ v.pb(j); k++; v.pb(a[w][j-i]); } ll resi=(ask(v)+1)/2; if(w==0)resi=k-resi; res+=resi; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...