# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675903 | VodkaInTheJar | Counting Mushrooms (IOI20_mushrooms) | C++14 | 0 ms | 208 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;
const int c = 50;
int use_machine(vector <int> x);
int count_mushrooms(int n) {
vector <int> as;
vector <int> bs;
as.push_back(0);
if (use_machine({0, 1}) == 1)
bs.push_back(1);
else
as.push_back(1);
if (use_machine({0, 2}) == 1)
bs.push_back(2);
else
as.push_back(2);
for (int i = 3; i <= c; i += 2) {
if ((int)as.size() >= 2) {
int cnt_bs = use_machine({as[0], i, as[1], i + 1});
if (cnt_bs == 3) {
bs.push_back(i);
bs.push_back(i+1);
}
else
if (cnt_bs == 2) {
bs.push_back(i);
as.push_back(i+1);
}
else
if (cnt_bs == 1) {
bs.push_back(i+1);
as.push_back(i);
}
else {
as.push_back(i);
as.push_back(i+1);
}
}
else {
int cnt_as = use_machine({bs[0], i, bs[1], i + 1});
if (cnt_as == 3) {
as.push_back(i);
as.push_back(i+1);
}
else
if (cnt_as == 2) {
bs.push_back(i+1);
as.push_back(i);
}
else
if (cnt_as == 1) {
bs.push_back(i);
as.push_back(i+1);
}
else {
bs.push_back(i);
bs.push_back(i+1);
}
}
}
int pos = c + 1, ans = (int)as.size();
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() / 2 - (cnt_b + 1) / 2;
else
as.push_back(nxt-1), ans += (int)temp.size() / 2 - 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... |