# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
714101 | Pherokung | Rarest Insects (IOI22_insects) | C++17 | 0 ms | 0 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>
#define pb push_back
using namespace std;
int min_cardinality(int n) {
int type = 0;
vector<int> in,out,in_temp,out_temp;
for(int i=0;i<n;i++){
move_inside(i);
if(press_button() > 1) move_outside(i), out.pb(i);
else type++, in.pb(i);
}
int be = 1, ed = n/type;
while(be <= ed){
int mid = (be+ed)/2, cnt = in.size();
in_temp.clear(), out_temp.clear();
for(auto x : out){
move_inside(x);
if(press_button() > mid) move_outside(x), out_temp.pb(x);
else cnt++, in_temp.pb(x);
if(cnt == mid * type) break;
}
if(cnt == mid * type){
be = mid+1;
in += in_temp;
out = out_temp;
}
else{
ed = mid-1;
out = in_temp;
}
}
return ed;
}