• 2024-12-28并查集
    并查集模板:#include<iostream>#include<vector>usingnamespacestd;//初始化父节点数组vector<int>fa;//查找根节点并进行路径压缩intfindParent(intx){if(x==fa[x])returnx;returnfa[x]=findParent(fa[x]);}//合并两个集合voidunionS