并查集
并查集
浪漫些许潦草
这个作者很懒,什么都没留下…
展开
-
hdu 畅通工程(并查集)
畅通工程原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1232Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?原创 2016-12-14 11:25:30 · 434 阅读 · 0 评论 -
poj Parity game(带权并查集)(hash离散化)
Parity gameDescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for ex原创 2017-03-06 20:14:14 · 591 阅读 · 2 评论 -
zoj Connections in Galaxy War(逆向并查集)
Connections in Galaxy WarIn order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War原创 2017-03-07 21:52:47 · 1191 阅读 · 0 评论 -
hdu 3038 How Many Answers Are Wrong(带权并查集)
How Many Answers Are WrongProblem DescriptionTT and FF are ... friends. Uh... very very good friends -________-bFF is a bad boy, he is always wooing TT to play the following game with原创 2017-03-04 16:09:14 · 2278 阅读 · 0 评论 -
CodeForces - 731C Socks(并查集)(贪心)
SocksArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Ars原创 2017-03-12 15:59:51 · 839 阅读 · 0 评论 -
nyoj 一笔画问题(并查集,欧拉路)
一笔画问题原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=42描述zyc从小就比较喜欢玩一些小游戏,其中就包括画一笔画,他想请你帮他写一个程序,判断一个图是否能够用一笔画下来。规定,所有的边都只能画一次,不能重复画。 输入第一行只有一个正整数N(N每组测试数据的第一行有两个正原创 2016-12-15 15:58:35 · 695 阅读 · 0 评论 -
poj 1984 Navigation Nightmare(带权并查集)
Navigation NightmareDescriptionFarmer John's pastoral neighborhood has N farms (2 <= N <= 40,000), usually numbered/labeled 1..N. A series of M (1 <= M < 40,000) vertical and horizontal road原创 2017-03-09 17:25:06 · 1357 阅读 · 0 评论 -
poj 2912 Rochambeau(带权并查集)(枚举)
RochambeauDescriptionN children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it is possible that some group is原创 2017-04-01 20:16:32 · 1057 阅读 · 1 评论 -
poj Supermarket(贪心)(并查集)(优先队列)
SupermarketDescriptionA 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 unit原创 2017-03-08 21:48:50 · 1051 阅读 · 0 评论 -
poj A Bug's Life(关系并查集)
A Bug's LifeDescriptionBackground Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only inter原创 2017-03-05 10:51:02 · 839 阅读 · 0 评论 -
poj Wireless Network(基础并查集)
Wireless NetworkDescriptionAn 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 afters原创 2017-02-28 21:26:59 · 704 阅读 · 0 评论 -
poj The Suspects(并查集)
The SuspectsSevere acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the bes原创 2016-12-20 16:37:35 · 405 阅读 · 0 评论 -
poj Find them, Catch them(关系并查集)
Find them, Catch themDescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However,原创 2016-12-31 15:10:05 · 729 阅读 · 0 评论 -
poj Cube Stacking(带权并查集)
Cube StackingFarmer 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 Bets原创 2016-12-20 20:12:38 · 532 阅读 · 0 评论 -
hdu 小希的迷宫(并查集)(连通无环图)
小希的迷宫Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路原创 2016-12-27 09:00:22 · 497 阅读 · 0 评论 -
poj Is It A Tree?(并查集)(连通无环图)
Is It A Tree?DescriptionA tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying原创 2017-03-01 15:07:51 · 562 阅读 · 0 评论 -
并查集
并查集先来个容易理解的并查集,特别容易理解http://blog.csdn.net/dellaserss/article/details/7724401/总结一下:并查集其实就是维护了几个动态的集合,集合中的每一个元素都标记了一个父节点,同一个集合的父节点是相同的。当一个元素的父节点就是它本身时,它就是这个集合的代表。并查集有三种操作:123这里用数组实现,原创 2016-12-14 11:43:57 · 382 阅读 · 0 评论 -
poj 食物链(种类并查集)(思路)
食物链Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。原创 2017-03-02 20:32:03 · 1161 阅读 · 0 评论 -
CodeForces - 698B Fix a Tree(并查集)
Fix a TreeA tree is an undirected connected graph without cycles.Let's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represent such a tr原创 2017-03-17 10:37:38 · 519 阅读 · 0 评论 -
hdu 6109 数据分割(并查集+set合并)
数据分割Problem Description小w来到百度之星的赛场上,准备开始实现一个程序自动分析系统。这个程序接受一些形如xi=xj 或 xi≠xj 的相等/不等约束条件作为输入,判定是否可以通过给每个 w 赋适当的值,来满足这些条件。输入包含多组数据。 然而粗心的小w不幸地把每组数据之间的分隔符删掉了。 他只知道每组数据都是不可满足的,且若把每组数据的最后一个约束条件去掉,则该组数据是可满原创 2017-08-16 08:16:34 · 552 阅读 · 0 评论