摘要:
思路:用并查集即可,每次合并的时候将小的集合合并到大的集合上去。理论上的平均复杂度是n*lgn*lgn。#include#include#include#include#include#include#define Maxn 100010#define LL long long#define Mod 1000000007int sz[Maxn],fa[Maxn];using namespace std;priority_queue q[Maxn];void init(){ for(int i=0;isz[y]){ q[x].push(s1); q[x].pus... 阅读全文