#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(x) (cout << (x))
#else
#define dbg(x)
#endif
using vi =vector<int>;
#define pb push_back
#define FOR(i, a, b) for (int i = a; i < b; i++)
int count_mushrooms(int n) {
vi isa(n, 0); isa[0] = 1;
for (int i = 1; i < n; i += 2) {
if (i == n - 1) {
isa[i] = 1 - use_machine(vi({0, i}));
} else {
int tl = 2 - use_machine(vi({i, 0, i+1}));
if (tl >= 1) isa[i] = 1;
if (tl >= 2) isa[i+1] = 1;
}
}
return accumulate(isa.begin(), isa.end(), 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |