#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n)
{
int ans = 0, type = 0;
for (int i = 0; i < n; ++i)
{
int l = i + 1;
int r = n - 1;
while (l <= r)
{
int mid = (l + r) / 2;
vector<int> query;
for (int j = i; j <= mid; ++j)
{
query.push_back(j);
}
int result = use_machine(query);
if (result == 0)
{
l = mid + 1;
}
else
{
r = mid - 1;
}
}
if (type == 0) ans += (r - i + 1);
i = r;
type = 1 - type;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |