最小生成树
使用kruskal算法求解
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
int n,m,ans;
struct node{
int u,v,cost;
}E[maxn];
bool cmp(node a, node b){
return a.cost < b.cost;
}
int father[maxn];
void init(){
for
最小生成树
使用kruskal算法求解
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
int n,m,ans;
struct node{
int u,v,cost;
}E[maxn];
bool cmp(node a, node b){
return a.cost < b.cost;
}
int father[maxn];
void init(){
for