# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658619 | pere_gil | Rarest Insects (IOI22_insects) | C++17 | 3056 ms | 300 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) {
queue<int> in,out;
for(int i=0;i<n;i++){
move_inside(i);
if(press_button()>1){
move_outside(i);
out.push(i);
}
else in.push(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)/2;
queue<int> new_in,new_out;
while(!out.empty()){
int u=out.front(); out.pop();
move_inside(u);
int q=press_button();
if(q>med){
move_outside(u);
new_out.push(u);
}
else new_in.push(u);
if(in.size()+new_in.size()==dif*med) break;
}
if(in.size()+new_in.size()==dif*med){
while(!new_in.empty()){
in.push(new_in.front()); new_in.pop();
}
while(!new_out.empty()){
out.push(new_out.front()); new_out.pop();
}
l=med;
}
else{
while(!new_in.empty()){
int u=new_in.front(); new_in.pop();
move_outside(u);
out.push(u);
}
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... |