Submission #411729

#TimeUsernameProblemLanguageResultExecution timeMemory
411729SuhaibSawalha1Counting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms200 KiB
#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 timeMemoryGrader output
Fetching results...