题面连接
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
关注
打赏