# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411729 | SuhaibSawalha1 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 200 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 ans = 1;
vector<int> a[2], v(n - 1);
iota(v.begin(), v.end(), 1);
for (int i = 1; i < min(n, 5); ++i) {
a[use_machine({0, v.back()})].push_back(v.back());
v.pop_back();
}
while (v.size() > 1) {
int res;
if (a[0].size() >= 3) {
res = use_machine({a[0][0], v.back(), a[0][1], v[v.size() - 2], a[0][2]});
ans += (res == 2) + 2 * (res == 0);
}
else {
res = use_machine({a[1][0], v.back(), a[1][1], v[v.size() - 2], a[1][2]});
ans += (res == 2) + 2 * (res == 4);
}
v.pop_back();
v.pop_back();
}
if (v.size()) {
ans += !use_machine({0, v[0]});
}
return ans + a[0].size();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |