![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
CFhM_R
所谓的光辉岁月,不是那些闪亮的日子,而是无人问津时,你对梦想的坚持
展开
-
【hdu1198】Farm Irrigation——并查集
Problem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square h原创 2016-02-24 23:23:42 · 363 阅读 · 0 评论 -
算法——并查集
并查集是一种树状数据结构,用来处理不相交的集合的关系,它的查找速度非常快,在并查集中只存在两种关系,要么是属于关系,要么是不想交的补集关系。并查集有四种基本操作,初始化,查询,合并以及判断是否属于同一集合,可以用数组实现,也可以用指针实现,北理ACM祖传的是数组实现的方法。用数组来完成指向父节点的操作。所以我们首先需要一个数组fa[]来存放各个元素的父亲节点。void init(int s原创 2016-02-24 23:33:38 · 398 阅读 · 0 评论 -
【poj1838】Bananas——并查集
BananaTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 2220 Accepted: 806DescriptionConsider a tropical forrest, represented as a matrix. The cell from原创 2016-02-25 00:04:26 · 412 阅读 · 0 评论 -
【hdu3635】Dragon Balls —— 并查集
题目: Dragon Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5393 Accepted Submission(s): 2036 Problem Description Five原创 2016-05-31 18:27:40 · 609 阅读 · 0 评论 -
【hdu3038】
题目:描述:题解:代码:#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 2e5 + 5;int fa[maxn], sum[maxn];int find(int x){ if(fa[x] == -1) return x; int tmp原创 2016-07-19 10:22:10 · 824 阅读 · 0 评论