bzoj 1083: [SCOI2005]繁忙的都市 并查集

→题目链接←


使n个点联通显然的是n-1条边

将边以长度从小到大排序,如果目前的边的两端点不在同一集合中,就选择这个边,这显然是最优的


代码:

#include
#include
#include

using namespace std;

struct edge{
	int s,t,len;
	friend bool operator < (edge a,edge b){
		return a.len


你可能感兴趣的:(BZOJ题解,————基础数据结构————,并查集)