
Union-find
文章平均质量分 73
candy糖酱
这个作者很懒,什么都没留下…
展开
-
poj-1611-The Suspects(水并查集)
题目链接:http://poj.org/problem?id=1611 题意:输入n个人,m个组。初始化0为疑似病例。输入m个小组,每组中只要有一个疑似病例,整组人都是疑似病例。相同的成员可以在不同的组。找出一共有多少个疑似病例。 解题思路:同组的同parent,查找,合并集合。最后将出现的每个组员的parent和0的parent相比较,统计便可。 AC代码: #include #incl原创 2014-02-27 15:18:54 · 872 阅读 · 0 评论 -
poj-2524(裸并查集)
题目链接: http://poj.org/problem?id=2524 题意: n个人,m对人宗教相同,输出一共有多少个不同的宗教。 代码如下: #include #include using namespace std; #define M 500100 int par[M]; int h[M]; int n, m; void init(int a) { for(i原创 2014-03-03 19:27:19 · 959 阅读 · 0 评论 -
1856-More is better-基础并查集
思路:注意n为0的时候输出1,还有内存。这题是原创 2014-04-30 22:37:43 · 1019 阅读 · 0 评论 -
HDU-1598-find the most comfortable road(暴力枚举+Kruskal最小生成树)
题目描述:原创 2014-05-06 20:20:56 · 1514 阅读 · 0 评论 -
Water Water Union-Find Set & Min-Spanning Tree Problems' Set~Orz【updating...】
【HDU】 1213 - How Many Tables 【基础 】原创 2014-04-30 10:42:18 · 864 阅读 · 0 评论