
并查集
love亦菲
业精于勤,荒于嬉;行成于思,毁于随。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu 1325
Is It A Tree?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17755 Accepted Submission(s): 3985Problem DescriptionA tree is a原创 2015-08-01 23:14:10 · 488 阅读 · 0 评论 -
csu 1326 The contest
1326: The contestTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 569 Solved: 181[Submit][Status][Web Board]Description 殷犇有很多队员。他们都认为自己是最强的,于是,一场比赛开始了~ 于是安叔主办了一场比赛,比赛有n个题目,每个题目都原创 2015-10-04 18:09:10 · 597 阅读 · 0 评论 -
hihocoder #1066 : 无间道之并查集
时间限制:20000ms单点时限:1000ms内存限制:256MB描述这天天气晴朗、阳光明媚、鸟语花香,空气中弥漫着春天的气息……额,说远了,总之,小Hi和小Ho决定趁着这朗朗春光出去玩。但是刚刚离开居住的宾馆不久,抄近道不小心走入了一条偏僻小道的小Hi和小Ho就发现自己的前方走来了几个彪形大汉,定睛一看还都是地地道道的黑人兄弟!小Hi和小Ho这下就慌了原创 2015-09-26 11:30:42 · 573 阅读 · 0 评论 -
并查集的路径压缩
这是朴素查找的代码,适合数据量不大的情况:int findx(int x){ int r=x; while(parent[r] !=r) r=parent[r]; return r;} 下面是采用路径压缩的方法查找元素:int find(int x) //查找x元素所在的集合,回溯时压缩路径{ if (x转载 2015-11-30 23:23:13 · 504 阅读 · 0 评论 -
hdu acm 1198 Farm Irrigation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8352 Accepted Submission(s): 3584Problem DescriptionBenny has a spacious farm land原创 2016-03-10 22:30:50 · 504 阅读 · 0 评论 -
pat 1021. Deepest Root (25)
A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root原创 2016-07-25 09:10:07 · 407 阅读 · 0 评论 -
pat 1107. Social Clusters (30)
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of th原创 2015-12-20 16:40:39 · 801 阅读 · 0 评论