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 pb push_back
int min_cardinality(int N) {
vector<int> v, alr_in;
move_inside(0);
v.pb(0);
for (int i = 1; i < N; i++) {
move_inside(i);
if (press_button() != 1) {
move_outside(i);
} else {
v.pb(i);
}
}
int lo = 1, hi = N / (int)v.size(), ans = -1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
vector<int> to_remove;
for (int i = 0; i < N; i++) {
if (!binary_search(v.begin(), v.end(), i)) {
if (!binary_search(alr_in.begin(), alr_in.end(), i)) {
move_inside(i);
}
if (press_button() > mid) {
move_outside(i);
} else {
to_remove.pb(i);
}
}
}
if ((int)to_remove.size() == (int)v.size() * (mid - 1)) {
ans = mid;
lo = mid + 1;
alr_in = to_remove;
sort(alr_in.begin(), alr_in.end());
} else {
hi = mid - 1;
for (auto i : to_remove) {
move_outside(i);
}
}
}
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... |