Submission #415810

#TimeUsernameProblemLanguageResultExecution timeMemory
415810SuhaibSawalha1Counting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
15 ms456 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int ans = 1; vector<int> a[2]; a[0] = {0}; vector<int> v(n - 1); iota(v.begin(), v.end(), 1); while (v.size()) { int ind = a[0].size() < a[1].size(); int use = min(a[ind].size(), v.size()); vector<int> ask; for (int i = 0; i < 2 * use; ++i) { if (i & 1) { ask.push_back(v.back()); v.pop_back(); } else { ask.push_back(a[ind][i / 2]); } } int res = use_machine(ask); a[ind ^ (res & 1)].push_back(ask.back()); if (ind) { ans += (res + 1) / 2; } else { ans += use - (res + 1) / 2; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...