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;
for(auto x : in_temp) in.pb(x);
out = out_temp;
}
else{
ed = mid-1;
out = in_temp;
}
}
return ed;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |