# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988520 | cnn008 | Rarest Insects (IOI22_insects) | C++17 | 115 ms | 1672 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 "bits/stdc++.h"
using namespace std;
#include "insects.h"
#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif
#define ll long long
const int N=1e5+5;
const int mod=1e9+7;
int min_cardinality(int n){
set <int> s;
int cad=0;
auto add = [&](int i) -> void{
s.insert(i);
move_inside(i);
};
auto del = [&](int i) -> void{
s.erase(i);
move_outside(i);
};
auto clear = [&]() -> void{
auto _s=s;
for(auto i:_s) del(i);
};
auto check = [&](int k) -> bool{
for(int i=0; i<n; i++){
add(i);
if(press_button()>k) del(i);
}
bool f=((int)s.size()>=cad*k);
clear();
return f;
};
for(int i=0; i<n; i++){
add(i);
if(press_button()==1) cad++;
else del(i);
}
clear();
int l=2,r=n/cad,ans=1;
while(l<=r){
int mid=(l+r)/2;
if(check(mid)){
ans=mid;
l=mid+1;
}else r=mid-1;
}
return ans;
}
/** /\_/\
* (= ._.)
* / >💖 \>💕
**/
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... |