# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307384 | arthur_nascimento | Counting Mushrooms (IOI20_mushrooms) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mushrooms.h"
#define pb push_back
using namespace std;
const int C = 100;
int count_mushrooms(int n) {
vector<int> A,B;
A.pb(0);
for(int i=1;i<min(C,n);i++){
vector<int> v;
v.pb(0);
v.pb(i);
int x = use_machine(v);
if(x) B.pb(i);
else A.pb(i);
}
int ans = A.size();
int eff = 0;
for(int i=C;i<n;i+=t-1){
int t = max(A.size(), B.size());
int use = 0;
if(B.size() > A.size()) use = 1;
vector<int> vec = A;
if(use) vec = B;
vector<int> v;
eff = 0;
for(int j=0;j<t;j++){
v.pb(vec[j]);
if(j < t-1 && i+j < n) v.pb(i+j), eff++;
}
int x = use_machine(v);
//printf("ff %d\n",eff);
if(use) ans += x/2;
else ans += eff - (x/2);
}
return ans;
}