# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604861 | CyberCow | Counting Mushrooms (IOI20_mushrooms) | C++17 | 3 ms | 296 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 <vector>
using namespace std;
vector<int> a, b;
int nsh[20006];
int count_mushrooms(int n) {
a.push_back(0);
int ans = 1, gt = 0;
for (int i = 1; i < min(75, n); i++)
{
if (use_machine({ 0, i }) == 1)
{
b.push_back(i);
nsh[i] = 1;
}
else
{
a.push_back(i);
nsh[1] = 0;
ans++;
}
}
if (n <= 75)
return ans;
int qan = 0, atb = 0, aq = 0, bq = 0, anc = 75;
if (a.size() < b.size())
atb = 1;
vector<int> x;
for (int i = 75; i < n; i++)
{
if (atb == 0)
{
x.push_back(a[aq]);
aq++;
x.push_back(i);
if (aq == a.size() - 1 || i == n - 1)
{
x.push_back(a[aq]);
ans += (2 * (i - anc) - use_machine(x))/2;
x.clear();
aq = 0;
anc = i;
}
}
else
{
x.push_back(b[bq]);
bq++;
x.push_back(i);
if (bq == b.size() - 1 || i == n - 1)
{
x.push_back(b[bq]);
ans += use_machine(x)/2;
x.clear();
bq = 0;
anc = i;
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |