# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675894 | VodkaInTheJar | Counting Mushrooms (IOI20_mushrooms) | C++14 | 0 ms | 300 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |