随笔分类 -  并查集

摘要:题目: https://ac.nowcoder.com/acm/problem/106585 思路: 与传统并查集的区别在于这种每个集合内部的上下关系用rank来维护,各个集合之间的合并因为是整个的所以可以用size来维护 size[i]为根为i的集合的大小 #include<stdio.h>con 阅读全文
posted @ 2021-06-07 22:32 废柴废柴少女 阅读(45) 评论(0) 推荐(0)
摘要:扩展域并查集 题目: 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[ 阅读全文
posted @ 2021-06-06 21:47 废柴废柴少女 阅读(580) 评论(0) 推荐(0)