随笔分类 - 并查集
摘要:题目: https://ac.nowcoder.com/acm/problem/106585 思路: 与传统并查集的区别在于这种每个集合内部的上下关系用rank来维护,各个集合之间的合并因为是整个的所以可以用size来维护 size[i]为根为i的集合的大小 #include<stdio.h>con
阅读全文
摘要:扩展域并查集 题目: https://ac.nowcoder.com/acm/problem/16884 x是A,x+n是B,x+2n是C #include<stdio.h>const int maxn=150000;int f[maxn];int find(int x){ return x==f[
阅读全文
浙公网安备 33010602011771号