# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052307 | aykhn | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 596 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;
const int B = 100;
int count_mushrooms(int n)
{
vector<int> v[2];
v[0] = {0};
int i = 1;
for (; i < n && max(v[0].size(), v[1].size()) < B + 1; i++) v[use_machine({0, i})].push_back(i);
int res = 0;
for (int j = i; j < n; j += B)
{
vector<int> q;
int sz = min(n, j + B) - j;
for (int k = j; k < min(n, j + B); k++)
{
if (v[0].size() > v[1].size())
{
q.push_back(v[0][k - j]);
q.push_back(k);
}
else
{
q.push_back(v[1][k - j]);
q.push_back(k);
}
}
if (v[0].size() > v[1].size())
{
q.push_back(v[0].back());
res += sz - (use_machine(q) / 2);
}
else
{
q.push_back(v[1].back());
res += use_machine(q) / 2;
}
}
return res + v[0].size();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |