
并查集
文章平均质量分 87
ctsas
这个作者很懒,什么都没留下…
展开
-
并查集 集合内的分类问题
并查集 集合内的分类问题普通的并查集对于集合内的元素无法分类,我们用一个数组表示其类型就行了。主要并查集在压缩路径的过程是动态维护的,表示类型类型也要随之而变。注意这儿的类型关系应该是线性的(像食物链的关系一样,是相对有等级的)调用val[x]时应先调用find(x),find()不止是查找,还有跟新x->根的所有关系的作用话不多说,直接上代码。不懂的可以看看这篇文章》》传送门#define原创 2017-02-03 16:51:58 · 615 阅读 · 0 评论 -
Wireless Network 并查集
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n原创 2017-01-20 20:39:05 · 373 阅读 · 0 评论 -
【poj-1182】食物链 并查集
食物链Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 66802 Accepted: 19713Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都原创 2017-01-20 20:52:42 · 9506 阅读 · 0 评论 -
【POJ】1703 Find them, Catch them 并查集
Find them, Catch themTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 43420 Accepted: 13356DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch a原创 2017-01-22 16:57:53 · 1084 阅读 · 0 评论 -
【POJ】1456 Supermarket 并查集
Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12319 Accepted: 5464DescriptionA supermarket has a set Prod of products on sale. It earns a profit px for each pr原创 2017-01-22 20:51:15 · 14005 阅读 · 1 评论 -
How Many Answers Are Wrong 并查集
题意:提问区间[a,b]的和为sum 是否与之前的信息矛盾。求矛盾提问数量思路让所有有关系的区间上下限的值组成集合。 取根的值为0,那么各元素的值为:区间[根,元素]的和。TT and FF are ... friends. Uh... very very good friends -________-bFF is a bad boy, he is always wooing TT to play the fo原创 2017-01-24 16:15:38 · 294 阅读 · 0 评论 -
POJ 1182 食物链(并查集) 详解
POJ 1182 食物链 (并查集) 详解参考做法比较经典的并查集的题目,主要是要理解路径压缩的过程。 用0 1 2 分别表示A B C的关系。 0吃1,1吃2,2吃0. 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。原创 2017-01-21 21:35:14 · 19873 阅读 · 0 评论 -
POJ - 1988 Cube Stacking [带权并查集&动态维护]
Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to perform P (1<=原创 2017-05-01 11:47:16 · 417 阅读 · 0 评论