摘要: /*本题为不是固定根的最小树形图,我们可以虚拟出一根来,然后在把这个根跟每个点相连,相连的点可以设为无穷大,或者设为所有边和大一点,比如为r,然后就可以利用最小树形图进行计算了,计算出的结果减去r,如果比r还大就可以认为通过这个虚拟节点我们连过原图中两个点,即原图是不连通的,我们就可以认为不存在... 阅读全文
posted @ 2016-11-18 16:15 hong-ll 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 有一副有向图,要求从根节点起能访问到所有的结点,且路径最短。即求最小树形图。 算法位朱刘算法, 裸的最小树形图,用朱—刘算法解决,具体实现过程如下:算法一开始先判断从固定根开始是否可达所有原图中的点,若不可,则一定不存在最小树形图。这一步是一个很随便的搜索,写多搓都行,不加废话。第二步,遍历所有... 阅读全文
posted @ 2016-11-18 16:13 hong-ll 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给你一个无向图,问如果这个无向图的最小生成树是唯一的就输出最小生成树的权值,否则输出Not Unique! 解题思路,求次小生成树,如果次小生成树中有何最小的权值一样的,则生成树不唯一,否则唯一用Kruskal,求最小生成树,然后枚举其中一个边去掉以后(n-1条),再求最小生成树,然后... 阅读全文
posted @ 2016-11-15 20:00 hong-ll 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 题目大意:s会分裂,然后从s到A的最小的步是多少。 解题思路:先bfs算出A或者S到任何点的距离,然后最求最小生成树,用dij或者prim都可以 #include#include#include#include#includeusing namespace std;const int m... 阅读全文
posted @ 2016-11-15 10:24 hong-ll 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever ma... 阅读全文
posted @ 2016-11-10 16:29 hong-ll 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm ... 阅读全文
posted @ 2016-11-10 15:49 hong-ll 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencie... 阅读全文
posted @ 2016-11-10 15:40 hong-ll 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 第一题和第二题都没有代码,,,,,,不会自己想办法 第三题: #include#includeint main(){ int a,b,i; const int maxn = 10; int B[maxn]; while(scanf("%d%d",&a,&b)!=EOF){... 阅读全文
posted @ 2016-11-07 19:55 hong-ll 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the ... 阅读全文
posted @ 2016-11-02 18:33 hong-ll 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code be... 阅读全文
posted @ 2016-11-02 15:45 hong-ll 阅读(142) 评论(0) 推荐(0) 编辑