![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构——并查集
邵光亮
要为自己喜欢的事情不留余力
展开
-
Codeforces 1315 D. Recommendations(贪心+并查集)
Description:VK news recommendation system daily selects interesting publications of one of nnn disjoint categories for each user. Each publication belongs to exactly one category. For each category i...原创 2020-02-24 12:02:42 · 2916 阅读 · 1 评论 -
Codeforces 1263D Secret Passwords (并查集)
Description:\quadOne unknown hacker wants to get the admin’s password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator’s office an...原创 2019-11-30 17:50:27 · 449 阅读 · 2 评论 -
POJ 1733 Parity game(离散化+并查集)
Description: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 subsequ...原创 2019-11-01 17:51:34 · 251 阅读 · 0 评论 -
POJ 1611 The Suspects(并查集)
Description: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 s...原创 2019-11-01 16:08:15 · 124 阅读 · 0 评论 -
hdu 1878 欧拉回路(并查集)
Problem Description欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 < N < 1000 )和边数M;随后的M行对应M条边,每行给出一对正整数,分别是该条边直接连通的两个节点的编号(节点从1到N编...原创 2019-09-25 17:14:12 · 227 阅读 · 0 评论 -
POJ 1456 Supermarket (贪心or并查集)
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 th...原创 2019-09-25 16:30:25 · 220 阅读 · 0 评论 -
ZOJ 3261 Connections in Galaxy War(并查集)
Description:In 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 began, some tunn...原创 2019-09-24 19:27:55 · 389 阅读 · 0 评论 -
POJ 2492 A Bug's Life(并查集)
DescriptionBackgroundProfessor 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 ...原创 2019-09-24 17:31:51 · 335 阅读 · 0 评论 -
HUD 3461 codelock (并查集+快速幂)
Description:A lock you use has a code system to be opened instead of a key. The lock contains a sequence of wheels. Each wheel has the 26 letters of the English alphabet 'a' through 'z', in order. I...原创 2019-06-16 22:16:30 · 636 阅读 · 0 评论 -
HDU1272 小希的迷宫(并查集)
Description:上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的...原创 2019-05-29 18:30:30 · 524 阅读 · 0 评论 -
CodeForces News Distribution (并查集)
Exampleinput7 53 2 5 402 1 21 12 6 7output4 4 1 4 4 2 2 n个人,m组关系,接下来m行。每行p个人,这p个人是朋友,朋友的朋友也是我的朋友。最后按顺序输出自己的朋友数+1.直接套并查集的板子不懂的可以参考这篇博客,点击这里路径压不压缩都可以,但是压缩以后时间会缩短AC代码:...原创 2019-05-16 20:03:06 · 586 阅读 · 0 评论 -
HDU 2120 Ice_cream's world I (并查集判环)
Description:ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall bet...原创 2019-09-10 11:14:59 · 598 阅读 · 0 评论 -
POJ 2253 Frogger(并查集+二分||Dijkstra)
DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of...原创 2019-08-27 10:09:42 · 511 阅读 · 0 评论 -
POJ 1456 Supermarket (贪心+并查集优化)
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 th...原创 2019-08-27 09:32:25 · 629 阅读 · 0 评论 -
POJ 1733 Parity game (路径压缩并查集+离散化)
DescriptionNow 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 subseque...原创 2019-08-26 17:20:48 · 643 阅读 · 0 评论 -
ZOJ 3261 Connections in Galaxy War (并查集+离线处理)
Description:In 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 began, some tunn...原创 2019-08-26 15:30:23 · 592 阅读 · 0 评论 -
POJ 1182 食物链(并查集)
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。此人对N个动物,用上述两种...原创 2019-08-26 15:18:01 · 611 阅读 · 0 评论