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 <vector>
#include <numeric>
using namespace std;
int min_cardinality(int n) {
int inside = 0;
vector<int> avail(n), navail, used;
iota(avail.begin(), avail.end(), 0);
int types = 0;
for (int i : avail) {
inside++;
move_inside(i);
if (press_button() == 1) {
types++;
used.push_back(i);
} else {
navail.push_back(i);
move_outside(i);
inside--;
}
}
swap(avail, navail);
navail.clear();
if (types == 1 || types == n) {
return 1 ^ n ^ types;
}
int l = 1, r = n - 1;
while (l < r) {
int m = (l + r) / 2;
int k = m + 1;
vector<int> vin, vout;
for (int i : avail) {
move_inside(i);
inside++;
if (press_button() > k) {
move_outside(i);
inside--;
vout.push_back(i);
} else {
vin.push_back(i);
}
}
if (inside < k * types) {
for (int u : vin) {
move_outside(u);
inside--;
}
avail = vin;
r = m;
} else {
avail = vout;
l = m + 1;
}
}
return l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |