文章
2
粉丝
46
获赞
1
访问
870
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110, M = 110, INF = 0x3f3f3f3f;
int n, m;
int p[N];
struct Edge
{
int a, b, w;
bool operator< (const Edge &W)const
{
return w < W.w;
}
}edges[N];
int find(int x)
{
if (p[x] != x) p[x] = find(p[x]);
return p[x];
}
int kruskal()
{
int res = 0, cnt = 0;
sort(edges, edges + n);
for (int i = 1; i <= m; i ++ )
p[i] = i;
for (int i = 0; i < n; i ++ )
{
int a = edges[i].a, b = edges[i].b, w = edges[i].w;
a = find...
登录后发布评论
暂无评论,来抢沙发