# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054591 | Ignut | Rarest Insects (IOI22_insects) | C++17 | 89 ms | 924 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.
/* Ignut
started: 11.08.2024
now: 12.08.2024
████████████████████████████████████████████████████████████████████
████████████████████████████████ ████████████████████████████████
██████████████████████████████ ██████████████████████████████
██████ ██████████████████ ██████████████████ ██████
██████ ██████████████ ██████████████ ██████
██████ ██ ████████████ ████████████ ██ ██████
██████ ████ ██████████ ██████████ ████ ██████
██████ ████ ██████████ ██████████ ████ ██████
██████ ████ ██████████ ██████████ ██████ ██████
██████ ██████ ██████████ ██████████ ██████ ██████
██████ ██████ ████████ ████████ ██████ ██████
██████ ██████ ██████ ██████ ██████ ██████
██████ ████ ████ ████ ████ ██████
██████ ██████████ ████ ██████████ ██████
██████ ██ ██████ ████████ ██████ ██ ██████
██████ ██████ ████████ ██████ ██████
██████ ██ ██ ██████
██████████████████████ ████ ████ ██████████████████████
████████████████████████ ██ ██ ████████████████████████
██████████████████████████ ██████████████████████████
██████████████████████████████ ██████████████████████████████
████████████████████████████████████████████████████████████████████
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void move_inside(int i);
void move_outside(int i);
int press_button();
int n;
vector<int> diff;
int Go(int maxCount) {
vector<int> in;
for (int i = 0; i < n; i ++) {
move_inside(i);
in.push_back(i);
// cout << "add " << i << " -> " << press_button() << '\n';
if (press_button() > maxCount) {
move_outside(i);
in.pop_back();
}
}
int res = in.size();
if (maxCount == 1) diff = in;
while (!in.empty()) move_outside(in.back()), in.pop_back();
// cout << maxCount << " : " << res << '\n';
return res;
}
int min_cardinality(int N) {
n = N;
int cntDiff = Go(1);
// for (int val : diff) cout << val << ' ';
// cout << '\n';
if (cntDiff <= 8) {
int minRes = N, sum = 0;
for (int i = 0; i < cntDiff - 1; i ++) {
vector<int> in;
in.push_back(diff[i]);
move_inside(diff[i]);
for (int j = diff[i] + 1; j < N; j ++) {
move_inside(j);
in.push_back(j);
// cout << "try " << j << ' ';
if (press_button() != in.size()) {
in.pop_back();
move_outside(j);
// cout << "! ";
}
}
// cout << '\n';
minRes = min(minRes, int(in.size()));
sum += in.size();
// cout << "have : " << in.size() << '\n';
// for (int val : in) cout << val << ' ';
// cout << '\n';
while (!in.empty()) {
move_outside(in.back());
in.pop_back();
}
}
minRes = min(minRes, N - sum);
return minRes;
}
int lo = 1, hi = N / cntDiff;
while (lo < hi) {
int mid = lo + (hi - lo + 1) / 2;
if (1ll * Go(mid) == 1ll * mid * cntDiff)
lo = mid;
else
hi = mid - 1;
}
return lo;
}
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... |