# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
605000 | lcj | Counting Mushrooms (IOI20_mushrooms) | C++17 | 123 ms | 220 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#include "mushrooms.h"
int count_mushrooms(int n) {
int rcount = 1;
int cnt = n;
int r1 = use_machine({0, 1});cnt -= r1;
if (n == 2) return cnt;
int r2 = use_machine({0, 2});cnt -= r2;
if (n == 3) return cnt;
bool inv = 0;
pii pa;
if (r1 == 1 && r2 == 1) {
inv = 1;
pa = {1, 2};
}
else if (r1 == 0) {
pa = {0, 1};
}
else {
pa = {0, 2};
}
for (int i = 3; i < n; i += 2)
{
if (i == n-1) {
int res = use_machine({0, i});
cnt -= res;
rcount += (1-res);
}
else {
int res = use_machine({i, pa.first, pa.second, i+1});
if (!inv) {
cnt -= res;
}
else {
rcount += res;
}
}
}
if (inv) {
return rcount;
}
return cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |