并查集
吃猫De鱼_
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
How Many Tables HDU - 1213
#include using namespace std; const int MAXN = 1000 + 10; int fa[MAXN], rank[MAXN]; int t, m, n; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } void init() { for (int i =原创 2017-11-30 22:43:34 · 215 阅读 · 0 评论 -
The Suspects POJ - 1611
#include #include using namespace std; const int MAXN = 30000 + 10; int fa[MAXN], rank[MAXN]; void init(int n) { rank[0] = 1; for (int i = 1; i < n; ++i) { fa[i] = i; r原创 2017-12-01 09:29:07 · 195 阅读 · 0 评论 -
Wireless Network POJ - 2236
WA了一发,要注意合并节点a到集合b的时候,要将a的整棵树都合并到b,而不是仅仅把a的父节点设置为b的父节点 #include #include using namespace std; const int MAXN = 1000 + 10; int fa[MAXN]; int n, d; struct Computer { int x, y; int statu;//是否修原创 2017-11-24 19:38:46 · 257 阅读 · 0 评论
分享