# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830506 | tolbi | Rarest Insects (IOI22_insects) | C++17 | 230 ms | 320 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"
int min_cardinality(int n) {
vector<int> par(n);
function<int(int)> find = [&](int node)->int{
if (par[node]==node) return node;
return par[node]=find(par[node]);
};
vector<int> sz(n,1);
iota(par.begin(), par.end(), 0);
vector<int> crr;
function<int()> findx;
findx = [&]()->int{
for (int i = 0; i < crr.size(); i++){
move_outside(crr[i]);
if (press_button()==1){
for (int j=0;j<=i;j++){
move_inside(crr[j]);
}
return i;
}
}
return 23;
};
for (int i = 0; i < n; i++){
move_inside(i);
if (press_button()>1){
int pos = crr[findx()];
sz[find(pos)]+=sz[find(i)];
sz[find(i)]=0;
par[i]=find(pos);
move_outside(i);
}
else crr.push_back(i);
}
int ans = n;
for (int i = 0; i < n; i++){
if (find(i)!=i) continue;
ans=min(ans,sz[i]);
}
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... |