# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303503 | galca | Counting Mushrooms (IOI20_mushrooms) | C++14 | 4 ms | 256 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"
using namespace std;
int count_mushrooms(int n) {
vector<int> knownZeros;
vector<int> knownOnes;
knownZeros.push_back(0);
vector<int> pairs;
pairs.push_back(0);
pairs.push_back(0);
if (n <= 128) {
for (int i = 1; i < n; i++) {
pairs[1] = i;
int c = use_machine(pairs);
if (c) {
knownOnes.push_back(i);
}
else {
knownZeros.push_back(i);
}
}
return knownZeros.size();
}
for (int i = 1; i < 128; i++) {
pairs[1] = i;
int c = use_machine(pairs);
if (c) {
knownOnes.push_back(i);
}
else {
knownZeros.push_back(i);
}
}
if (knownOnes.size() >= knownZeros.size()) {
int totalZeros = knownZeros.size();
for (int i = 128; i < n; i+=64) {
vector<int> m;
for (int j = 0; j < 64; j++) {
if ((i + j) < n) {
m.push_back(knownOnes[j]);
m.push_back(i+j);
}
}
int c = use_machine(m);
if (c % 1) {
++totalZeros;
--c;
}
totalZeros += c / 2;
}
return totalZeros;
}
else {
int totalOnes = knownOnes.size();
for (int i = 128; i < n; i += 64) {
vector<int> m;
for (int j = 0; j < 64; j++) {
if ((i + j) < n) {
m.push_back(knownZeros[j]);
m.push_back(i + j);
}
}
int c = use_machine(m);
if (c % 1) {
++totalOnes;
--c;
}
totalOnes += c / 2;
}
return n - totalOnes;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |