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"
#ifndef EVAL
#include "stub.cpp"
#endif
#include "bits/stdc++.h"
using namespace std;
int min_cardinality(int n) {
vector<int> used, rem;
for(int i=0;i<n;i++){
move_inside(i);
if(press_button() > 1){
move_outside(i);
rem.push_back(i);
} else {
used.push_back(i);
}
}
int cnt = used.size();
for(auto x : used){
move_outside(x);
}
swap(used, rem);
auto check = [&](int mid){
vector<int> in, rem;
for(auto x : used){
move_inside(x);
if(press_button() > mid){
move_outside(x);
rem.push_back(x);
} else {
in.push_back(x);
}
}
for(auto x : in) move_outside(x);
if((int)in.size() < mid * cnt){
swap(used, in);
return false;
} else {
swap(used, rem);
return true;
}
};
int res = 1;
while((int)used.size() >= cnt){
int mid = used.size() / cnt;
if(check(mid)){
res += mid;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |