# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824257 | thimote75 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 9 ms | 336 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;
using idata = vector<int>;
const int QK = 186;
int count_mushrooms(int n) {
idata Av = { 0 };
idata Bv = { };
for (int i = 1; i < n && i < QK; i ++) {
int res = use_machine({ 0, i });
if (res == 0) Av.push_back(i);
else Bv.push_back(i);
}
int offset = 0;
int multiplier = 1;
if (Bv.size() > Av.size()) {
Bv.swap(Av);
offset = n;
multiplier = -1;
}
int total = Av.size();
for (int i = QK; i < n; i += Av.size() - 1) {
idata templ;
int cnt = 0;
for (int j = 0; j < Av.size() - 1; j ++) {
templ.push_back(Av[j]);
if (i + j >= n) continue ;
cnt ++;
templ.push_back(i + j);
}
templ.push_back(Av[Av.size() - 1]);
int res = use_machine(templ);
int c0 = (cnt) - (res >> 1);
total += c0;
}
return offset + multiplier * total;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |