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) {
int D = 0;
vector<int> can, in, out;
for (int i = 1; i < N; i++) {
move_inside(i);
if (press_button() == 2) {
move_outside(i);
out.push_back(i);
} else {
D++;
in.push_back(i);
}
}
can = out;
int l = 2, r = N / D, ans = 1, cnt = D;
while (l <= r) {
int m = (l + r + 1) / 2;
in.resize(0), out.resize(0);
for (int i : can) {
move_inside(i);
if (press_button() > m) {
move_outside(i);
out.push_back(i);
} else {
in.push_back(i);
cnt++;
}
}
if (cnt == D * m) {
l = m + 1;
ans = m;
can = out;
} else {
r = m - 1;
can = in;
for (auto x : can) {
move_outside(x);
cnt--;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |