# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
825251 | benjaminkleyn | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 208 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)
{
int A = 1, cnt = 0;
int i = 0;
for (; i + 4 < n; i += 4)
{
int x = use_machine({i+0, i+1, i+2, i+3, i+4});
if (x == 0)
cnt += (A ? 4 : 0);
else if (x == 1)
{
int y = use_machine({i+0, i+3, i+1, i+4, i+2});
if (y == 1)
cnt += (A ? 1 : 3);
else if (y == 2)
cnt += (A ? 4 : 0);
else if (y == 3)
cnt += 2;
else if (y == 4)
cnt += (A ? 3 : 1);
}
else if (x == 2)
{
int y = use_machine({i+1, i+0, i+2, i+4, i+3});
if (y <= 2)
cnt += (A ? 3 : 1);
else if (y == 3)
cnt += 2;
else if (y == 4)
cnt += (A ? 1 : 3);
}
else if (x == 3)
{
int y = use_machine({i+3, i+1, i+2, i+0, i+4});
if (y == 2)
cnt += 2;
else if (y == 3)
cnt += (A ? 3 : 1);
}
else if (x == 4)
cnt += 2;
A ^= (x % 2);
}
cnt += A;
for (int j = i + 1; j < n; j++)
cnt += 1 - use_machine({0, j});
return cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |