这道题其实就是无线通讯网的双倍经验啦,只是在输出的时候不同罢了.还是一样的\(kruskal\)算法,但是在求的时候,应该在\(now=n-k+1\)的时候结束.本来到\(n-k\)就行了的,但是由于\(n-k+1\)这条边是在应该部落里面的,不能算,所以要找到第一个不在一个部落里面的边. 代码: #include <bits/stdc++.h> using namespace std; struct node{ int l , r; double w; }; int n , k , tot…
题目链接 [洛谷传送门] 题解 很显然,当这个点不是割点的时候,答案是\(2*(n-1)\) 如果这个点是割点,那么答案就是两两被分开的联通分量之间求组合数. 代码 #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 500005; struct edge { int to, nt; } E[N << 1]; int dfn[N], low[N], H[N], sz[N];…