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