# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
817423 | math_rabbit_1028 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 11 ms | 316 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 b = max((int)sqrt(n), 2);
vector<int> Alist, Blist;
Alist.push_back(0);
int i;
for (i = 1; i < n; i++) {
if (use_machine({i, Alist[0]}) == 0) Alist.push_back(i);
else Blist.push_back(i);
if (Alist.size() == b || Blist.size() == b) break;
}
i++;
int ans = Alist.size();
for (; i < n; i += b) {
vector<int> seq;
if (Alist.size() == b) {
for (int j = i; j < min(i + b, n); j++) {
seq.push_back(Alist[j - i]);
seq.push_back(j);
}
ans += (min(i + b, n) - i) - (use_machine(seq) + 1) / 2;
}
else {
for (int j = i; j < min(i + b, n); j++) {
seq.push_back(Blist[j - i]);
seq.push_back(j);
}
ans += (use_machine(seq) + 1) / 2;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |