# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830547 | tolbi | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 208 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 <bits/stdc++.h>
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "insects.h"
int min_cardinality(int n) {
function<int(int)> f;
vector<int> hash(n);
iota(hash.begin(), hash.end(), 0);
for (int i = n-1; i >= 0; i--){
swap(hash[i],hash[ayahya()%(i+1)]);
}
f = [&](int x)->int{
int ans = 0;
vector<int> crr;
for (int i = 0; i < n; i++){
crr.push_back(hash[i]);
move_inside(hash[i]);
if (press_button()>x){
ans++;
crr.pop_back();
move_outside(hash[i]);
}
}
for (int i = 0; i < crr.size(); ++i)
{
move_outside(crr[i]);
}
return ans;
};
int diff = n-f(1);
int l = n/diff, r = n;
while (l<r){
int mid = l+(r-l+1)/2;
if (f(mid)>n-(mid*diff)){
r=mid-1;
}
else l = mid;
}
return l;
}
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... |