# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
825482 | benjaminkleyn | Counting Mushrooms (IOI20_mushrooms) | C++17 | 8 ms | 444 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>
using namespace std;
int count_mushrooms(int n)
{
vector<int> A(1, 0), B;
int i = 1;
int cnt = 1;
while (i < n)
{
vector<int> query;
if (A.size() >= B.size())
{
for (int j : A)
{
query.push_back(j);
query.push_back(i++);
if (i >= n)
break;
}
int x = use_machine(query);
cnt += query.size() / 2 - (x + 1) / 2;
if (x % 2)
B.push_back(query.back());
else
A.push_back(query.back());
}
else
{
for (int j : B)
{
query.push_back(j);
query.push_back(i++);
if (i >= n)
break;
}
int x = use_machine(query);
cnt += (x + 1) / 2;
if (x % 2)
A.push_back(query.back());
else
B.push_back(query.back());
}
}
return cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |