题目大意:略。
解题思路:kruskal的变形,外填一个汇点0,将建造飞机场看成是于0点建立一条边,费用为一个飞机场的价格。然后就是裸的kruskal算法,不过要注意的是如果只有一个点与0点相连,那么就要判断该点的飞机场是否为必须建立的,如果不为必须建立的则要减掉。
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
const int N = 1005;
const int M = 15005;
typedef long long ll;
struct line {
int u, v;
ll l;
}way[M];
ll ans, costA, costB;
int n, m, k, t, cnt, f[N];
int get (int x) {
return f[x] ==