# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736744 | jk410 | Rarest Insects (IOI22_insects) | C++17 | 85 ms | 236 KiB |
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 n, ret0;
bool used[2000],check[2000][2];
int mySolve[2001];
int solve(int x) {
int& ret = mySolve[x];
if (ret != -1)
return ret;
ret = ret0;
for (int i = 0; i < n; i++) {
if (check[i][0] || check[i][1])
continue;
move_inside(i);
used[i] = true;
if (press_button() > x) {
used[i] = false;
move_outside(i);
}
if (used[i])
ret++;
}
return ret;
}
int min_cardinality(int _n) {
n = _n;
memset(mySolve, -1, sizeof(mySolve));
int cnt = solve(1);
int l = 1, r = n / cnt, ans;
while (l <= r) {
int m = (l + r) >> 1;
if (solve(m) == cnt * m) {
ret0 = solve(m);
for (int i = 0; i < n; i++) {
if (used[i])
check[i][0] = true;
}
ans = m;
l = m + 1;
}
else {
for (int i = 0; i < n; i++) {
if (!used[i])
check[i][1] = true;
if (used[i] && !check[i][0])
move_outside(i);
}
r = m - 1;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |