# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580000 | Vanilla | 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 <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
const int block = 141;
int cd2 (int x) {
return x / 2 + (x % 2);
}
int count_mushrooms(int n) {
vector <int> s0 = {0}, s1;
vector <int> prf = {0};
// int block = sqrt(n);
int sf = 0;
for (int i = 1; i < 2 * block; i++){
prf.push_back(i);
sf = use_machine(prf);
((sf % 2) ? s1: s0).push_back(i);
}
bool rev = 0;
int rs = s0.size();
int oth = 0;
if (s1.size() > s0.size()) {
rev = 1;
swap(s0, s1);
}
vector <int> idx;
for (int i = block * 2; i < n; i++){
idx.push_back(s0[i % block]);
idx.push_back(i);
if (i % block == block - 1 || i == n - 1) {
oth+=cd2(use_machine(idx));
idx.clear();
}
}
if (!rev) oth = n - block * 2 - oth;
return rs + oth;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |