# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
628087 | haojiandan | Rarest Insects (IOI22_insects) | C++17 | 62 ms | 432 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 n;
int p[10000];
int min_cardinality(int _n) {
n=_n; vector<int> V; int cnt=0;
for (int i=0;i<n;i++) p[i]=i; random_shuffle(p,p+n);
for (int i=0;i<n;i++) {
move_inside(p[i]);
if (press_button()>1) move_outside(p[i]),V.push_back(p[i]); else cnt++;
}
if (cnt==1) return n;
if (cnt==2) {
for (int i=0;i<n;i++) move_inside(i);
return n-press_button();
}
int l=2,r=n/cnt,mid,res=1;
int lst=1;
while (l<=r) {
mid=(l+r)>>1;
vector<int> V1,V2; int c=0;
for (int &x : V) {
move_inside(x);
if (press_button()>mid) move_outside(x),V2.push_back(x); else c++,V1.push_back(x);
}
if (c==cnt*(mid-lst)) {
res=mid; V.swap(V2); lst=mid; l=mid+1;
} else {
r=mid-1; for (int &x : V1) move_outside(x); V.swap(V1);
}
}
return res;
}
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... |