题目链接:https://oj.gxu.edu.cn/problem/1038
先来解释一下题目:我们要让任意两个点都能够直接或间接连接在一起;
还有一个条件是在我们选择的所有路里面,让最大的路尽量小;
有一点绕口qwq;还是直接上代码吧!
//并查集
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
int u,v,w;
bool operator < (const node &m) const{
return w < m.w;}
//因为我们定义的类不在C++库里,所以我们要运算符重载
}p[10005];
void print(int n,int* fa