# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781038 | Josia | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 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;
int count_mushrooms(int n) {
vector<int> is = {0}, isnot;
int pos = 1;
while(pos < n && is.size()<100 && isnot.size()<100) {
if (use_machine({0, pos})) isnot.push_back(pos);
else is.push_back(pos);
pos++;
}
if (is.size() > isnot.size()) {
vector<int> check;
int res = is.size();
for (int i = pos; i<n; i+=is.size()) {
for (int j = i; j<i+is.size(); j++) {
check.push_back(is[j-i]);
check.push_back(j);
}
}
int ans;
if (check.empty()) ans = 0;
else ans = use_machine(check);
res += (ans+1)/2;
return res;
}
else {
vector<int> check;
int res = isnot.size();
for (int i = pos; i<n; i+=isnot.size()) {
for (int j = i; j<i+isnot.size(); j++) {
check.push_back(isnot[j-i]);
check.push_back(j);
}
}
int ans;
if (check.empty()) ans = 0;
else ans = use_machine(check);
res += (ans+1)/2;
res = n-res;
return res;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |