多学习。

摘要: AcWing837. 连通块中点的数量 题解 #include <iostream> #include <cstdio> using namespace std; const int N = 1e5 + 10; int p[N], cnt[N], n, m, x, y; int find(int x 阅读全文
posted @ 2022-05-18 21:29 czyaaa 阅读(54) 评论(0) 推荐(1)
摘要: 并查集 处理问题 1.将两个集合合并 2.询问两个集合是否在一个集合当中 暴力思维 1.询问两个元素是否在一个集合 belong[x] = a; //元素x在a集合 if(belong[x] == belong[y]) //判断a与b是否在一个集合,复杂度O(1) 2.合并集合 //将a,b集合合并 阅读全文
posted @ 2022-05-18 20:46 czyaaa 阅读(115) 评论(0) 推荐(0)