# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303736 | denkendoemeer | Counting Mushrooms (IOI20_mushrooms) | C++14 | 4 ms | 384 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<bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
int count_mushrooms(int n)
{
vector<int>nr[2];
vector<int>aux;
nr[0].push_back(0);
int i,lim=130,ok,cnt=0,rez,ok2,ram,j;
for(i=1;i<n && max(nr[0].size(),nr[1].size())<2;i++)
nr[use_machine({0,i})].push_back(i);
if (nr[1].size()==2)
ok=1;
else
ok=0;
for(;i<n && max(nr[0].size(),nr[1].size())<lim;i=i+2)
{
if (i+1<n)
rez=use_machine({nr[ok][0],i,nr[ok][1],i+1});
else
rez=use_machine({nr[ok][0],i,nr[ok][1]});
if (rez&2)
ok2=1;
else
ok2=0;
nr[ok^ok2].push_back(i);
if (i+1<n)
ok2=rez&1,nr[ok^ok2].push_back(i+1);
}
while(i<n)
{
if (nr[1].size()==max(nr[0].size(),nr[1].size()))
ok=1;
else
ok=0;
ram=min((int)max(nr[0].size(),nr[1].size()),n-i);
aux.clear();
for(j=0;j<ram;j++)
aux.push_back(nr[ok][j]),aux.push_back(i+j);
rez=use_machine(aux);
if (rez%2==1)
rez++;
if (ok)
cnt=cnt+rez/2;
else
cnt=cnt+rez-rez/2;
i+=ram;
}
return nr[0].size()+cnt;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |