# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604590 | Mher | Counting Mushrooms (IOI20_mushrooms) | C++14 | 131 ms | 336 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"
using namespace std;
int count_mushrooms(int n) {
vector<int> cl(n, -1);
cl[0] = 1;
if (n == 2)
{
return 2 - use_machine({0, 1});
}
cl[1] = 1 - use_machine({0, 1});
cl[2] = 1 - use_machine({0, 2});
bool t;
int x, y;
if (cl[0] == cl[1])
{
t = true;
x = 0;
y = 1;
}
else if (cl[0] == cl[2])
{
t = true;
x = 0;
y = 2;
}
else
{
t = false;
x = 1;
y = 2;
}
for (int i = 3; i < n - 1; i += 2)
{
int res = use_machine({x, i, y, i + 1});
if (res == 0)
{
cl[i] = cl[i + 1] = t;
}
else if (res == 1)
{
cl[i] = t;
cl[i + 1] = !t;
}
else if (res == 2)
{
cl[i] = !t;
cl[i + 1] = t;
}
else
{
cl[i] = cl[i + 1] = !t;
}
}
if (n % 2 == 0)
{
cl[n - 1] = 1 - use_machine({0, n - 1});
}
int ans = 0;
for (int i = 0; i < n; i++)
ans += cl[i];
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |