并查集
weixin_44705665
这个作者很懒,什么都没留下…
展开
-
POJ 1308 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 i...原创 2019-08-13 16:05:10 · 86 阅读 · 0 评论 -
HDU 1272 并查集判环
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的...原创 2019-08-13 10:25:09 · 51 阅读 · 0 评论 -
POJ 1611 并查集
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-08-13 11:28:12 · 64 阅读 · 0 评论 -
HDU 1232 并查集入门
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? **Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每行给出...原创 2019-08-12 21:05:50 · 62 阅读 · 0 评论 -
HDU 1213 并查集入门
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-08-12 20:40:33 · 86 阅读 · 0 评论 -
HihoCoder - 1515 带权并查集
小Hi的学校总共有N名学生,编号1-N。学校刚刚进行了一场全校的古诗文水平测验。学校没有公布测验的成绩,所以小Hi只能得到一些小道消息,例如X号同学的分数比Y号同学的分数高S分。小Hi想知道利用这些消息,能不能判断出某两位同学之间的分数高低?Input第一行包含三个整数N, M和Q。N表示学生总数,M表示小Hi知道消息的总数,Q表示小Hi想询问的数量。以下M行每行三个整数,X, Y和S。...原创 2019-08-14 19:38:29 · 59 阅读 · 0 评论 -
POJ 1988 带权并查集
Farmer 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 Betsy to perform ...原创 2019-08-14 19:34:26 · 86 阅读 · 0 评论 -
POJ 2236 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...原创 2019-08-14 11:12:00 · 74 阅读 · 0 评论 -
HDU 3038 带权并查集
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 should write...原创 2019-08-13 21:20:02 · 59 阅读 · 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个动物,用上述两种说法,一句接一句地说出K句话,这K句话...原创 2019-08-13 17:23:58 · 48 阅读 · 0 评论 -
codeforces 1213G (树分治+并查集)
You are given a weighted tree consisting ofnnvertices. Recall that a tree is a connected graph without cycles. Verticesuiuiandviviare connected by an edge with weightwiwi.You are givenmmque...原创 2019-09-13 09:25:38 · 298 阅读 · 0 评论