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;
#define MAX 2020
int chk[MAX];
int num[MAX];
int min_cardinality(int N) {
int K;
K = 0;
int i;
int on = 0;
for (i = 0; i < N; i++) {
move_inside(i);
if (press_button() > 1) move_outside(i);
else num[i] = 1, chk[i] = 1, on++;
}
int l, r;
K = on;
l = 1, r = N / K + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
vector<int> nb;
for (i = 0; i < N; i++) {
if (!chk[i] && !num[i]) {
move_inside(i);
if (press_button() > mid) {
nb.push_back(i);
move_outside(i);
}
else {
chk[i] = 1;
on++;
}
}
if (on == mid * K) break;
}
if (on == mid * K) {
for (i = 0; i < N; i++) if (chk[i]) num[i] = 1;
l = mid;
}
else {
for (auto v : nb) num[v] = -1;
for (i = 0; i < N; i++) if (chk[i] && !num[i]) chk[i] = 0, move_outside(i), on--;
r = mid;
}
}
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... |