# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736906 | onlk97 | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 208 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) {
mt19937 mt(time(nullptr));
vector <int> v;
for (int i=0; i<N; i++) v.push_back(i);
shuffle(v.begin(),v.end(),mt);
int cnt=0;
set <int> s;
for (int i=0; i<N; i++){
move_inside(v[i]);
s.insert(v[i]);
int tp=press_button();
if (tp>1){
move_outside(v[i]);
s.erase(v[i]);
}
}
for (int i:s) move_outside(i);
int l=1,r=N;
while (l<r){
int mid=(l+r+1)/2;
for (int i=0; i<N; i++){
move_inside(v[i]);
s.insert(v[i]);
int tp=(i+1>=mid?press_button():0);
if (tp>mid){
move_outside(v[i]);
s.erase(v[i]);
}
}
if (s.size()==mid*cnt) l=mid;
else r=mid-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... |