# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390853 | AlexPop28 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 15 ms | 308 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;
#ifdef LOCAL_DEFINE
const int K = 2;
#else
const int K = 100;
#endif
int count_mushrooms(int n) {
if (n <= K) {
int ans = 0;
for (int i = 1; i < n; ++i) {
vector<int> curr = {0, i};
ans += use_machine(curr);
}
return n - ans;
}
vector<int> pos_a, pos_b;
int i;
for (i = 1; (int)max(pos_a.size(), pos_b.size()) < K; ++i) {
vector<int> curr = {0, i};
if (use_machine(curr) == 0) {
pos_a.emplace_back(i);
} else {
pos_b.emplace_back(i);
}
}
bool type = false;
auto pos = pos_a;
if (pos_b.size() > pos_a.size()) {
type = true;
pos = pos_b;
}
int ans = pos_a.size() + 1;
while (i < n) {
vector<int> curr;
for (int j = 0; j < K; ++j) {
curr.emplace_back(pos[j]);
if (i == n) break;
if (j + 1 < K) curr.emplace_back(i++);
}
int total = (curr.size() - 1) / 2;
int ret = use_machine(curr) / 2;
if (!type) ret = total - ret;
ans += ret;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |