# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
835386 | aykhn | Counting Mushrooms (IOI20_mushrooms) | C++14 | 3 ms | 308 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"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int BLOCK=150;
vector<int>a, b;
int count_mushrooms(int n)
{
a.pb(0);
for(int i=1; i<min(n, 2*BLOCK); i++)
{
int cnt=use_machine({0, i});
if(cnt) b.pb(i);
else a.pb(i);
}
if (n <= 2*BLOCK) return a.size();
if(a.size()>b.size())
{
int ansb=b.size();
for(int i=2*BLOCK; i<n; i++)
{
vector<int>cur;
int pos=0;int pi = i;
for(int j=i; j<min(n, (int)(pi+a.size())); j++)
{
cur.pb(a[pos++]);
cur.pb(j);
i = j;
}
int ret=use_machine(cur);
ansb+=(ret/2);
}
return n-ansb;
}
else
{
int ansa=a.size();
for(int i=2*BLOCK; i<n; i++)
{
vector<int>cur;
int pos=0;int pi = i;
for(int j=i; j<min(n, (int)(pi+b.size())); j++)
{
cur.pb(b[pos++]);
cur.pb(j);
i = j;
}
int ret=use_machine(cur);
ansa+=(ret/2);
}
return ansa;
}}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |