代码改变世界

随笔分类 -  并查集

并查集扩展。。。。。

2012-03-31 16:35 by javaspring, 338 阅读, 收藏,
摘要: 这篇文章转自http://blog.csdn.net/niushuai666/article/details/6981689题目链接:http://poj.org/problem?id=1182解题思路:这道题是并查集题目中的经典。。。而且比普通并查集提高了一个档次,下面在基础并查集的前提上讲解并查集的真正用法。基础回顾:find()函数找根结点的两种写法如下:第一种递归:[cpp]view plaincopyintfind(intx){returnx==pre[x]?x:find(pre[x]);}第二种:[cpp]view plaincopyintfind(intx){introot,t. 阅读全文

杭电 1829 A Bug's Life 经典并查集

2012-03-31 16:32 by javaspring, 316 阅读, 收藏,
摘要: 卧槽,写这道题写了两天啊,,,两天啊,,,容易吗。。。搞基的bug伤不起啊。。。。并查集扩展,题目:A Bug's LifeTime Limit: 15000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3921Accepted Submission(s): 1266Problem DescriptionBackgroundProfessor Hopper is researching the sexual behavior of a rare species of 阅读全文