您当前的位置: 首页 >  算法

MangataTS

暂无认证

  • 0浏览

    0关注

    423博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AcWing 859. Kruskal算法求最小生成树(稀疏图)

MangataTS 发布时间:2022-02-10 11:33:33 ,浏览量:0

题面连接

https://www.acwing.com/problem/content/861/

思路

没啥好说的,就是贪心+破圈法,然后不断将最短的边加入集合中,可以参考我这篇博客 https://acmer.blog.csdn.net/article/details/118560004

代码
#include
#include
#include
using namespace std;
#define N 100010

struct node{
    int from,to;
    long long cost;
}E[N*2];

int fa[N],n,m;

bool cmp(node a,node b){
    return a.cost            
关注
打赏
1665836431
查看更多评论
0.1343s