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;
const int MAX_N=2005;
int p[MAX_N],ele[MAX_N];
int find_set(int n){
return (p[n]==n) ? n : p[n]=find_set(p[n]);
}
bool same_set(int a, int b){
return find_set(a)==find_set(b);
}
void union_set(int a, int b){
a=find_set(a),b=find_set(b);
if(a==b) return;
ele[a]+=ele[b];
p[b]=a;
}
int min_cardinality(int n) {
iota(p,p+MAX_N,0);
for(int i=0;i<n;i++) ele[i]=1;
for(int i=0;i<n;i++){
move_inside(i);
for(int j=i+1;j<n;j++){
if(same_set(i,j)) continue;
move_inside(j);
if(press_button()==2) union_set(i,j);
move_outside(j);
}
move_outside(i);
}
int res=1e9;
for(int i=0;i<n;i++)
res=min(res,ele[find_set(i)]);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |