# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893109 | Trisanu_Das | Rarest Insects (IOI22_insects) | C++17 | 108 ms | 1352 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) {
vector<int> in;
for (int i = 0; i < N; i++) {
in.push_back(i);
move_inside(i);
if (press_button() >= 2) {
in.pop_back();
move_outside(i);
}
}
int diff = in.size();
if (diff == 1) return N;
function<bool(int)> check = [&](int x) {
for (int i : in) move_outside(i);
in.clear();
for (int i = 0; i < N; i++) {
in.push_back(i);
move_inside(i);
if (press_button() > x) {
in.pop_back();
move_outside(i);
}
}
return in.size() == x * diff;
};
int l = 1, r = N / diff;
while (l <= r){
int m = (l + r) >> 1;
if (check(m)) l = m + 1;
else r = m - 1;
}
return r;
}
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... |