并查集
cherish__lin
I want to be better!
展开
-
小雷的冰茶几(并查集)
Problem Description 小雷有个特殊的癖好,平时喜欢收藏各种稀奇古怪的东西,譬如。。。。,还有。。。。,也包括。。。。。小雷是一个喜欢分享的童鞋,这次小雷又给大家带来一套神奇的东西,那就是举世无双的冰茶几! 顾名思义,这些茶几被冰冻住了,最主要的是他们是易碎品,毕竟被冻住了。因此小雷要很小心翼翼的移动他们。一些茶几是冻在一起的,因此一套冰茶几分为好几部分,并且如果茶几A与B冻在一...原创 2019-02-15 14:02:51 · 238 阅读 · 3 评论 -
L2-010 排座位 (25 分)(简单并差集)
布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。 输入格式: 输入第一行给出3个正整数:N(≤100),即前来参宴的宾客总人数,则这些人从1到N编号;M为已知两两宾客之间的关系数;K为查询的条数。随后M行,每行给出一对宾客之间的关系,格式为:宾客1 宾客2 ...原创 2019-03-15 18:10:44 · 499 阅读 · 0 评论 -
G - Bear and Friendship Condition(并查集+无向完全图)
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures). There arenmembers, numbered1thro...原创 2019-03-08 07:45:19 · 263 阅读 · 0 评论 -
F. Asya And Kittens(并查集)
Asya loves animals very much. Recently, she purchasednnkittens, enumerated them from11andnnand then put them into the cage. The cage consists of one row ofnncells, enumerated with integers fro...原创 2019-03-01 23:34:38 · 414 阅读 · 0 评论 -
E - 食物链 (并查集经典题)
动物王国中有三类动物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个动物,用上述两种说法,一句接一句地说出K句话,...原创 2019-02-17 23:06:48 · 201 阅读 · 0 评论 -
D - How Many Answers Are Wrong (带权并查集)
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 shou...原创 2019-02-17 23:04:26 · 141 阅读 · 0 评论 -
C - 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...原创 2019-02-17 13:41:13 · 189 阅读 · 0 评论 -
B - 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...原创 2019-02-17 13:39:50 · 256 阅读 · 0 评论 -
H - 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...原创 2019-02-17 13:36:18 · 214 阅读 · 0 评论 -
J - 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 gend...原创 2019-02-17 13:32:40 · 237 阅读 · 0 评论 -
M - 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. There ...原创 2019-02-17 13:29:40 · 187 阅读 · 0 评论 -
L - 小希的迷宫 (并查集判环)
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的...原创 2019-02-16 13:05:10 · 231 阅读 · 0 评论 -
A - Wireless Network POJ - 2236 (并查集)
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...原创 2019-02-15 16:13:55 · 219 阅读 · 0 评论 -
SDUT2937->人活着系列之寻找最完美的人生(Prim算法)
Problem Description 也许,人活着就是要尝试人世间的酸甜苦辣,喜怒哀乐,经历从婴儿到老人的一个过程吧!能看,能想,能爱,能恨,这就是活人与死人的区别。不要想着死后会怎样,谁也不知道。所以要好好的活着,宽待自己,好好珍惜身边的人! 现在,上帝之手宽恕与你。把你人生中所要经历的所有的酸甜苦辣全部摆在你的面前。你一生需要经历n种事情。每种事情都有一个权值x。上帝给了你n-1个时光...原创 2019-01-12 01:03:16 · 226 阅读 · 0 评论 -
数据结构实验之图论九:最小生成树
Problem Description 有n个城市,其中有些城市之间可以修建公路,修建不同的公路费用是不同的。现在我们想知道,最少花多少钱修公路可以将所有的城市连在一起,使在任意一城市出发,可以到达其他任意的城市。 Input 输入包含多组数据,格式如下。 第一行包括两个整数n m,代表城市个数和可以修建的公路个数。(n <= 100, m <=10000) 剩下m...原创 2019-02-15 14:36:09 · 186 阅读 · 0 评论 -
小鑫的城堡(并查集)
Problem Description 从前有一个国王,他叫小鑫。有一天,他想建一座城堡,于是,设计师给他设计了好多简易图纸,主要是房间的连通的图纸。小鑫希望任意两个房间有且仅有一条路径可以相通。小鑫现在把设计图给你,让你帮忙判断设计图是否符合他的想法。比如下面的例子,第一个是符合条件的,但是,第二个不符合,因为从5到4有两条路径(5-3-4和5-6-4)。 Input 多组输入,每组第一行...原创 2019-02-15 14:20:58 · 130 阅读 · 0 评论 -
C. Edgy Trees(并查集+数学)
You are given a tree (a connected undirected graph without cycles) ofnnvertices. Each of then−1n−1edges of the tree is colored in either black or red. You are also given an integerkk. Consider s...原创 2019-03-22 07:42:41 · 374 阅读 · 0 评论