题目
分析
给 s s s 的邻接边弄一个 Δ \Delta Δ 值加在边权上,然后做最小生成树,易知 Δ \Delta Δ 越大, s s s 的度越小,因此可以 WQS 二分。实现把 s s s 的邻接边和非邻接边分别排好序,做的时候归并即可。
代码
#include <bits/stdc++.h>
int Read() {
int x = 0; bool f = false; char c = getchar();
while (c < '0' || c > '9')
f |= c == '-', c = getchar();
while (c >= '0' && c <= '9')
x = x * 10 + (c ^ 48), c = getchar();
return f ? -x : x;
}
typedef std::pair<int, int