# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742656 | doowey | Rarest Insects (IOI22_insects) | C++17 | 128 ms | 468 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>
#include "insects.h"
using namespace std;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
int min_cardinality(int n) {
int val;
set<int> in;
set<int> cand;
for(int i = 0 ; i < n; i ++ ){
move_inside(i);
val = press_button();
cand.insert(i);
if(val > 1){
move_outside(i);
}
else{
in.insert(i);
}
}
int dist = in.size();
int l = 1;
int r = n/dist + 1;
int mid;
while(l + 1 < r){
mid = (l + r) / 2;
if(mid * dist > n){
r = mid;
continue;
}
for(auto i : cand){
if(!in.count(i)){
move_inside(i);
val = press_button();
if(val > mid){
move_outside(i);
}
else{
in.insert(i);
}
}
}
if(in.size() == mid * dist){
l = mid;
}
else{
r = mid;
cand = in;
for(auto q : in){
move_outside(q);
}
in.clear();
}
}
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... |