![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
While.True
这个作者很懒,什么都没留下…
展开
-
畅通工程 (并查集模板题)
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每行给出一...原创 2018-08-15 21:14:10 · 141 阅读 · 0 评论 -
还是畅通工程 (带权并查集)
某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行对应村庄间的距离,每行给出一对正...原创 2018-08-15 21:16:45 · 100 阅读 · 0 评论 -
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...原创 2018-08-15 21:18:46 · 153 阅读 · 1 评论 -
Ubiquitous Religions (并查集模板题)
There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli...原创 2018-08-15 21:21:14 · 126 阅读 · 0 评论 -
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...原创 2018-08-15 21:22:35 · 174 阅读 · 0 评论 -
Dragon Balls (并查集)
Five hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to gather all of the dragon balls together.His country has N cities ...原创 2018-08-16 09:29:55 · 759 阅读 · 0 评论 -
P2024 [NOI2001]食物链
题目描述动物王国中有三类动物 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 吃...原创 2019-03-13 21:27:37 · 745 阅读 · 1 评论 -
算法提高 最小方差生成树
算法提高 最小方差生成树 时间限制:1.0s 内存限制:256.0MB问题描述给定带权无向图,求出一颗方差最小的生成树。输入格式输入多组测试数据。第一行为N,M,依次是点数和边数。接下来M行,每行三个整数U,V,W,代表连接U,V的边,和权值W。保证图连通。n=m=0标志着测试文件的结束。输出格式对于每组数据,输出最小方差,四舍五入到0.01。...原创 2019-03-16 16:32:24 · 375 阅读 · 0 评论