# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642238 | czhang2718 | Rarest Insects (IOI22_insects) | C++17 | 5 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) {
int ans=0;
vector<int> v(n);
iota(v.begin(), v.end(), 0);
int d=0;
for(int i=0; i<n; i++){
move_inside(v[i]);
int c=press_button();
if(c>1) move_outside(v[i]);
else d++;
}
if(d==1) return n;
vector<bool> inside(n);
for(int k=31-__builtin_clz(n/d); k>=0; k--){
int cnt=0;
for(int x:v) inside[x]=0;
for(int i=0; i<v.size(); i++){
move_inside(v[i]);
int c=press_button();
if(c>(1<<k)) move_outside(v[i]);
else cnt++, inside[v[i]]=1;
}
vector<int> v2;
if(cnt==(1<<k)*d){
for(int x:v){
if(!inside[x]) v2.push_back(x);
}
ans+=(1<<k);
}
else{
for(int x:v){
if(inside[x]) v2.push_back(x);
}
}
swap(v,v2);
}
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... |