最小生成树
文章平均质量分 83
俱往矣_wpt
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
并查集
#include int f[1000]={0},n,m,k,sum=0; void init() { int i; for(i=1;i<=n;i++) f[i]=i; //开始每个强盗的头都是自己 return; } int getf(int v) { if(f[v]==v) //判断强盗的头是不是自己 return v; else {原创 2017-07-24 17:49:13 · 329 阅读 · 0 评论 -
POJ1679 判断是否是唯一的最小树
The Unique MSTTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 34447 Accepted: 12567DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Sp...原创 2018-05-20 09:38:41 · 379 阅读 · 0 评论 -
Ubiquitous Religions POJ - 2524
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-02-02 10:47:50 · 269 阅读 · 0 评论 -
hdu 4463 Outlets
Problem DescriptionIn China, foreign brand commodities are often much more expensive than abroad. The main reason is that we Chinese people tend to think foreign things are better and we are willing t...原创 2017-09-26 15:28:12 · 349 阅读 · 0 评论 -
Kruskal 算法模板题
描述 随着小Hi拥有城市数目的增加,在之间所使用的Prim算法已经无法继续使用了——但是幸运的是,经过计算机的分析,小Hi已经筛选出了一些比较适合建造道路的路线,这个数量并没有特别的大。 所以问题变成了——小Hi现在手上拥有N座城市,且已知其中一些城市间建造道路的费用,小Hi希望知道,最少花费多少就可以使得任意两座城市都可以通过所建造的道路互相到达(假设有A、B、C三座城市,只需要在AB之间和原创 2017-08-03 09:57:16 · 573 阅读 · 0 评论 -
poj 1797 Heavy Transportation Dijkstra&&Kruskal
Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cust...原创 2017-08-06 16:12:01 · 955 阅读 · 0 评论 -
POJ2253 Frogger Kruskal||Dijkstra
Freddy 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 tourists' sun...原创 2017-08-17 15:55:24 · 292 阅读 · 0 评论 -
hdu 2682
There are N (2<=N<=600) cities,each has a value of happiness,we consider two cities A and B whose value of happiness are VA and VB,if VA is a prime number,or VB is a prime number or (VA+VB) is a prime原创 2017-08-03 10:58:02 · 415 阅读 · 0 评论 -
hdu 1863 畅通工程
省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( 行对应村庄间道路的成本,每行给出一对正整数,分别是原创 2017-08-03 10:48:07 · 328 阅读 · 0 评论 -
zoj 1203
There exists a world within our world A world beneath what we call cyberspace. A world protected by firewalls, passwords and the most advanced security systems. In this world we hide our d原创 2017-08-03 10:41:13 · 368 阅读 · 0 评论 -
hdu 5253
老 Jack 有一片农田,以往几年都是靠天吃饭的。但是今年老天格外的不开眼,大旱。所以老 Jack 决定用管道将他的所有相邻的农田全部都串联起来,这样他就可以从远处引水过来进行灌溉了。当老 Jack 买完所有铺设在每块农田内部的管道的时候,老 Jack 遇到了新的难题,因为每一块农田的地势高度都不同,所以要想将两块农田的管道链接,老 Jack 就需要额外再购进跟这两块农田高度差相等长度的管道。原创 2017-08-03 10:34:21 · 317 阅读 · 0 评论 -
zoj 1586 QS Network
In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they need to buy two network adapters原创 2017-08-03 10:13:44 · 352 阅读 · 0 评论 -
hdu 1301 Jungle Roads
The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so原创 2017-08-03 10:05:19 · 659 阅读 · 2 评论 -
最小生成树 Prime算法 和 Kruskal算法
最小生成树 保证一个图中的所有节点可以到达其他的任何节点,且连接这些节点的线的总和最小,此时这些节点和线组成最小生成树。 如上面的图的最小生成树就是:10+11+12+8+16+19+7+16=99 Prime算法: 在prime算法中,先从任何一个节点A(可以是任何一个节点,对最小生成树的构造没有影响)出发,记录和节点A有连接的所有线,这部分在代码中是: ...原创 2019-07-08 18:26:50 · 1270 阅读 · 0 评论
分享