# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029072 | 42kangaroo | Rarest Insects (IOI22_insects) | C++17 | 44 ms | 1028 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 "insects.h"
#include "bits/stdc++.h"
using namespace std;
int min_cardinality(int N) {
set<int> inside, outside;
for (int i = 0; i < N; ++i) {
move_inside(i);
if (press_button() > 1) {
outside.insert(i);
move_outside(i);
} else {
inside.insert(i);
}
}
int k = inside.size();
int l = 1, r = N/k + 1;
while (l + 1 < r) {
int m = (l + r + 1)/2;
set<int> nIn, nOut;
for (auto e: outside) {
move_inside(e);
if (press_button() > m) {
nOut.insert(e);
move_outside(e);
} else nIn.insert(e);
}
if ((inside.size() + nIn.size()) == m*k) {
l = m;
outside = nOut;
inside.insert(nIn.begin(), nIn.end());
} else {
r = m;
for (auto e: nIn) {
move_outside(e);
}
outside = nIn;
}
}
return l;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |