# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771659 | t6twotwo | Counting Mushrooms (IOI20_mushrooms) | C++17 | 3071 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 "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int count_mushrooms(int N) {
vector<int> a, p(N - 1);
int mn = 10000;
iota(p.begin(), p.end(), 1);
while (mn >= 10000) {
shuffle(p.begin(), p.end(), rng);
int x = use_machine(p);
if (x < mn) {
mn = x;
a = p;
}
}
int ans = 1;
for (int i = 0; i < N - 1;) {
bool f = use_machine({0, a[i]}) == 0;
vector<int> p{a[i]};
if (f) {
ans++;
}
if (++i == N - 1) {
break;
}
for (int j = 0; ; j++) {
if (i + (1 << j) > N - 1) {
j = -1;
continue;
}
for (int k = i; k < i + (1 << j); k++) {
p.push_back(a[k]);
}
if (use_machine(p) != 0) {
if (j == 0) {
break;
}
for (int k = 0; k < (1 << j); k++) {
p.pop_back();
}
j = -1;
} else {
if (f) {
ans += 1 << j;
}
i += 1 << j;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |