# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658623 | pere_gil | Rarest Insects (IOI22_insects) | C++17 | 100 ms | 424 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"
using namespace std;
int min_cardinality(int n) {
vector<int> in,out;
for(int i=0;i<n;i++){
move_inside(i);
if(press_button()>1){
move_outside(i);
out.push_back(i);
}
else in.push_back(i);
}
int dif=(int)in.size();
if(dif==1) return n;
int l=1,r=n/dif+1;
while(l<r){
int med=l+(r-l+1)/2;
vector<int> new_in,new_out;
while(out.size()){
int u=out[out.size()-1];
out.pop_back();
move_inside(u);
int q=press_button();
if(q>med){
move_outside(u);
new_out.push_back(u);
}
else new_in.push_back(u);
if(in.size()+new_in.size()==dif*med) break;
}
if(in.size()+new_in.size()==dif*med){
for(int i: new_in) in.push_back(i);
for(int i: new_out) out.push_back(i);
l=med;
}
else{
for(int i: new_in){
move_outside(i);
out.push_back(i);
}
r=med-1;
}
}
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... |