Submission #675894

#TimeUsernameProblemLanguageResultExecution timeMemory
675894VodkaInTheJarCounting Mushrooms (IOI20_mushrooms)C++14
0 / 100
0 ms300 KiB
#include <bits/stdc++.h> using namespace std; int use_machine(vector <int> x); int count_mushrooms(int n) { vector <int> as; vector <int> bs; as.push_back(0); int pos = 1, ans = 1; while (pos < n) { if ((int)as.size() >= (int)bs.size()) { int nxt = min(n, pos + (int)as.size()); vector <int> temp; for (int i = pos; i < nxt; i++) { temp.push_back(as[i-pos]); temp.push_back(i); } int cnt_b = use_machine(temp); if (cnt_b & 1) bs.push_back(nxt-1), ans += (int)temp.size() - (cnt_b + 1) / 2; else as.push_back(nxt-1), ans += (int)temp.size() - cnt_b / 2; pos = nxt; } else { int nxt = min(n, pos + (int)bs.size()); vector <int> temp; for (int i = pos; i < nxt; i++) { temp.push_back(bs[i-pos]); temp.push_back(i); } int cnt_a = use_machine(temp); if (cnt_a & 1) as.push_back(nxt-1), ans += (cnt_a + 1) / 2; else bs.push_back(nxt-1), ans += cnt_a / 2; pos = nxt; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...