# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000614 | kunzaZa183 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 7 ms | 596 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 "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
int sup;
vector<int> zeros(1, 0), ones;
int res;
for (int i = 1; i < n; i++) {
vector<int> vi;
vi.push_back(0);
vi.push_back(i);
// for (auto a : vi) cout << a << " ";
// cout << "\n";
res = use_machine(vi);
if (res == 1)
ones.push_back(i);
else
zeros.push_back(i);
sup = i;
if (max(zeros.size(), ones.size()) == 100) break;
}
sup++;
int zi = zeros.size(), oi = ones.size();
while (1) {
if (sup == n) break;
if (zeros.size() >= ones.size()) {
vector<int> send;
send.push_back(zeros.front());
int ct = 0;
for (int i = 1; i < zeros.size(); i++) {
if (sup == n) break;
send.push_back(sup++);
send.push_back(zeros[i]);
ct++;
}
res = use_machine(send);
res /= 2;
oi += res, zi += ct - res;
} else {
vector<int> send;
send.push_back(ones.front());
int ct = 0;
for (int i = 1; i < ones.size(); i++) {
if (sup == n) break;
send.push_back(sup++);
send.push_back(ones[i]);
ct++;
}
res = use_machine(send);
res /= 2;
zi += res, oi += ct - res;
}
}
return zi;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |