Kruscal
- 题目描述
- AC Code
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 10005;
struct edge{
int u,v;
ll d;
}e[maxn];
inline bool cmp(const edge &e1,const edge &e2){
return e1.d < e2.d;
}
int f[maxn] = {
0};
int n,m;
ll ans = -1;
int findf(int x){
if(x == f[x]) return x;
return f[x] = findf(f[x]);
}
void Kruscal(){
sort(e+1,e+1+m,cmp);
int cnt = 0;
for(int i=1;i<=m;i++){
int eu = findf(e[i].u