
并查集
coldfresh
那我们开始吧
展开
-
危险系数(又名:风险度量)(并查集)
问题描述 抗日战争时期,冀中平原的地道战曾发挥重要作用。地道的多个站点间有通道连接,形成了庞大的网络。但也有隐患,当敌人发现了某个站点后,其它站点间可能因此会失去联系。我们来定义一个危险系数DF(x,y):对于两个站点x和y (x != y), 如果能找到一个站点z,当z被敌人破坏后,x和y不连通,那么我们称z为关于x,y的关键点。相应的,对于任意一对站点x和y,危险系数DF(x,y)就表示为这两原创 2017-04-07 00:32:43 · 1484 阅读 · 0 评论 -
In Touch HDU- 5361(最短路+并查集)
There are n soda living in a straight line. soda are numbered by 1,2,…,n from left to right. The distance between two adjacent soda is 1 meter. Every soda has a teleporter. The teleporter of i-th soda...原创 2018-04-05 14:37:10 · 417 阅读 · 0 评论 -
Parity game POJ - 1733 (离散化+种类并查集)
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...原创 2018-04-04 17:40:00 · 207 阅读 · 0 评论 -
Minimum spanning tree for each edge CodeForces - 609E(ST算法+树链剖分(或倍增LCA)+最小生成树)
Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning tree t...原创 2018-03-21 13:49:34 · 379 阅读 · 0 评论 -
(pat)A1107. Social Clusters
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A “social cluster” is a set of people who have some of th...原创 2018-03-13 17:50:18 · 286 阅读 · 0 评论 -
Marriage Match II HDU - 3081 (二分答案+最大流+并查集)
Presumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house we used to play when we are kids. What a happy time as so many原创 2017-10-30 18:14:36 · 299 阅读 · 0 评论 -
Travel HDU - 5441 (带权并查集+离线)
Jack likes to travel around the world, but he doesn’t like to wait. Now, he is traveling in the Undirected Kingdom. There are nn cities and mm bidirectional roads connecting the cities. Jack hates wait原创 2017-09-22 14:28:47 · 368 阅读 · 0 评论 -
A Bug's Life HDU - 1829 (并查集)
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 gend原创 2017-09-21 17:37:55 · 332 阅读 · 0 评论 -
Conquer a New Region HDU - 4424(带权并查集的dp)
The wheel of the history rolling forward, our king conquered a new region in a distant continent. There are N towns (numbered from 1 to N) in this region connected by several roads. It’s confirmed th原创 2017-09-29 21:51:53 · 396 阅读 · 0 评论 -
FFF at Valentine HDU - 6165 (并查集+tarjan+缩点+拓扑排序)
At Valentine’s eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly.原创 2017-08-24 21:28:37 · 379 阅读 · 0 评论 -
How Many Answers Are Wrong HDU - 3038(种类并查集)
TT and FF are … friends. Uh… very very good friends -__-b FF 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 should write down a原创 2017-07-23 19:38:12 · 409 阅读 · 0 评论 -
食物链 POJ - 1182(种类并查集)
动物王国中有三类动物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-07-23 19:35:35 · 320 阅读 · 0 评论 -
【51nod】小k的技术(tarjan+带权并查集)
思路:用tarjan缩点以后,在带权并查集,需判断一个并查集里,是否含有强连通分量,如果有贡献就是点集大小,如果没有减1. 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #defin...原创 2018-09-04 19:14:30 · 306 阅读 · 0 评论