并查集
YCQ_Lancet
骐骥一跃,不能十步,驽马十驾,功在不舍
展开
-
POJ 1984 Navigation Nightmare
Farmer 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 roads each of varying lengths (1 <= length <=原创 2017-06-17 08:52:54 · 291 阅读 · 0 评论 -
HDU 3038 How Many Answers Are Wrong 带权并查集
TT 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 him. This is a very humdrum game. To begin with, TT sho原创 2017-06-14 17:03:36 · 261 阅读 · 0 评论 -
POJ 2912 Rochambeau 带权并差集(食物连变形)
N 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 empty). You don’t kn原创 2017-06-13 23:52:04 · 322 阅读 · 0 评论 -
食物链
动物王国中有三类动物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。 此人对N个动物,用上述两种说法,一句接一句地原创 2017-06-11 09:08:39 · 429 阅读 · 0 评论 -
POJ 2492 A Bug's Life 带权并查集!
Background 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 interact with bugs of the opposite gen原创 2017-06-12 16:58:42 · 231 阅读 · 0 评论 -
hdu 1325 Is It A Tree?
A 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 the following properties.Th原创 2017-06-11 20:55:20 · 187 阅读 · 0 评论 -
HDU 1272 小希的迷宫(图论+STL应用)
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的原创 2017-06-11 17:41:52 · 244 阅读 · 0 评论 -
HDU 1213 How Many Tables
Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, a原创 2017-06-09 20:46:52 · 173 阅读 · 0 评论 -
POJ1611:The Suspects
Severe 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 best strategy is to s原创 2017-06-09 20:08:37 · 229 阅读 · 0 评论 -
poj2236 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-06-09 19:16:36 · 172 阅读 · 0 评论 -
Roads and Libraries
The Ruler of HackerLand believes that every citizen of the country should have access to a library. Unfortunately, HackerLand was hit by a tornado that destroyed all of its libraries and obstructed it原创 2017-06-18 08:38:00 · 369 阅读 · 0 评论 -
POJ-1456 Supermarket 贪心 并查集优化
A 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 the moment the s原创 2017-06-17 10:39:39 · 288 阅读 · 0 评论 -
POJ 1733 Parity game 带权并查集+离散化处理
Now 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 example the subsequence from the t原创 2017-06-15 11:05:28 · 610 阅读 · 0 评论