#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define get use_machine
int count_mushrooms(int n)
{
vector<int> v={0},v1;
int ans=1;
for (int i=1;i<n;)
{
bool b=0;
if (v.size()<v1.size())
swap(v,v1), b=1;
int m=v.size();
vector<int> c;
int tot=0;
for (int id=0;i<n && id<m;i++,id++)
c.push_back(v[id]), c.push_back(i), tot++;
if (b) swap(v,v1);
int x=get(c);
if (b)
{
ans+=(x+1)/2;
if (x%2) v.push_back(c.back());
else v1.push_back(c.back());
}
else
{
ans+=tot-(x+1)/2;
if (x%2) v1.push_back(c.back());
else v.push_back(c.back());
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |