![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
smallacmer
这个作者很懒,什么都没留下…
展开
-
http://poj.org/problem?id=1456&&并查集
DescriptionA supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from t原创 2011-10-22 13:27:23 · 539 阅读 · 0 评论 -
Connect the Cities&&http://acm.hdu.edu.cn/showproblem.php?pid=3371
最小生成树变形题,不解释,这里输入量比较多,最好用一下输入外挂。。。AC代码:#include#include#include#include#include#include#include#define N 80000#define M 505using namespace std;typedef struct{ int x; int y;原创 2012-07-26 10:36:37 · 785 阅读 · 0 评论 -
http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1187&&Hole Breaker
问题描述 XadillaX wants a big hole to store some *&@#(*&@!#(*&!)(@&#^& things. So he bought a Hole Breaker.The ground is an N * N square. The breaker will break a 1 * 1 square hole in the ground per s原创 2012-07-07 11:33:17 · 1208 阅读 · 0 评论 -
并查集剖析
1、 概述并查集(Disjoint set或者Union-find set)是一种树型的数据结构,常用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。2、 基本操作并查集是一种非常简单的数据结构,它主要涉及两个基本操作,分别为:A. 合并两个不相交集合B. 判断两个元素是否属于同一个集合(1) 合并两个不相交集合(Union(x,y))合并操作很简单原创 2012-05-08 10:05:12 · 473 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=431
这一题真是纠结啊,,,一开始用c++超时,,,,,最后全改成c才行,,赤裸裸的并查集应用。。。代码:#include#include#include#includeusing namespace std;int father[10005],num[10005],d[10005];int n,m;int Find(int x){ if(father[x]==x) retur原创 2011-11-06 16:48:39 · 673 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=3371
这是今天xd弄的一个专题,,,,很是坑爹,,,c++过了,但是g++就是过不了,,,让我纠结了半个多小时,,,悲催,,,prim算法:#include#include#define N 505#define M 99999999#define FOR(i,s,t) for(int i=(s);i<=(t);++i)using namespace std;int n,m原创 2011-11-03 18:44:26 · 783 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=129
#include#include#define N 10005using namespace std;int parent[N];int r[N];void make(){ for(int i=0;i<N;i++) { parent[i]=i; r[i]=0; }}int find_set(int x){ return parent[x]==x?x:find_se原创 2011-11-03 11:26:23 · 779 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1272
题目大意:小希要做一个迷宫,迷宫中任意两个房间有且仅有一条路径可以相通(除非走了回头路)。这样,就需要用到并查集了(赤裸裸的),对于输入的两个顶点,判断是否在同一个集合内,是的话,就是存在多条通路了,而对于一个迷宫,所有的点最后必须在同一个集合,处理好这两个问题,就可以了有一个比较特殊的情况,就是输入的那一组数据只有两个0,必须输出 Yes网上有很多人写了这个题目的解题报告,但大家都是原创 2011-11-02 21:46:39 · 606 阅读 · 0 评论 -
http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?cid=791&pid=1001&ojid=0
#include#define N 1005#define FOR(i,s,t) for(int i=(s);i<=(t);i++)using namespace std;int n,m,sum;int father[N];void make_set(){ FOR(i,1,n) father[i]=i; sum=n; } int find_set(int a)原创 2011-11-02 20:30:03 · 1040 阅读 · 0 评论 -
Matrix&&2012 Multi-University Training Contest 2
Problem DescriptionMachines have once again attacked the kingdom of Xions. The kingdom of Xions has N cities and N-1 bidirectional roads. The road network is such that there is aunique path betwee原创 2012-07-28 10:29:16 · 949 阅读 · 0 评论