题意:
求最小生成树的边长和.
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 30;
int f[MAXN];
int n;
typedef struct edge
{
int u,v,w;
edge(){}
edge(int _u, int _v, int _w):u(_u),v(_v),w(_w){}
}edge;
vector<edge> g;
bool cmp(edge a, edge b)
{
return a.w<b.w;
}
int find_set(int x)
{
if(f[x]!=x)
f[x] = find_set(f[x]);
return f[x];
}
int Kruskal()
{
sort(g.begin(),g.end(),cmp);
......
阅读全文