并查集
wyc_
技术之路是千里之行,莫功利方能行更远
展开
-
POJ 1703 Find them, Catch them
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 34390 Accepted: 10607 Description The police office in Tadu City decides to say ends to the chaos, as launch actio原创 2015-04-29 11:03:20 · 289 阅读 · 0 评论 -
并查集II
1. Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutiv原创 2014-10-10 19:58:53 · 405 阅读 · 0 评论 -
并查集
并查集:一种树型的数据结构,用于处理一些不相交集合的合并及查询问题。 对于数组中的元素,我们如何表示元素a与元素b属于一个集合呢?比较容易想到的方法就是如果两个元素属于同一个集合,我们就将对应下标的数组中的值设为一个相同的标记来表示。为了区分不同的集合,每个集合的标记都应该是唯一的,一个比较好的方法就是取该标记为集合元素的最小值。我们看一下查找的过程,假设该数组为father[MAX],原创 2014-10-10 17:17:59 · 513 阅读 · 0 评论