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 <bits/stdc++.h>
#include "insects.h"
using namespace std;
const int maxn = 2010;
bool in[maxn];
pair<bool, int> p(int x, int N) {
for (int i = 0; i < N; ++i) {
move_inside(i);
in[i] = 1;
if (press_button() > x) {
move_outside(i);
in[i] = 0;
}
}
for (int i = 0; i < N; ++i) {
if (in[i]) {
move_outside(i);
}
}
int cnt = 0, bad = 0;
for (int i = 0; i < N; ++i) {
if (in[i]) {
move_inside(i);
if (press_button() >= x) {
move_outside(i);
bad += 1;
}
cnt += 1;
in[i] = 0;
}
}
return {cnt == bad * (x - 1), bad};
}
int min_cardinality(int N) {
pair<bool, int> temp;
int lo = 1, hi = min(N, 1000);
while (lo < hi) {
int mid = (lo + hi + 1) / 2;
if ((temp = p(mid, N)).first) lo = mid;
else hi = mid-1;
}
if (lo == 1000 && temp.second == 1) return N;
return lo;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |