图论
文章平均质量分 79
Wabrush
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
SDUT 2144 图结构练习——最小生成树
Problem Description 有n个城市,其中有些城市之间可以修建公路,修建不同的公路费用是不同的。现在我们想知道,最少花多少钱修公路可以将所有的城市连在一起,使在任意一城市出发,可以到达其他任意的城市。 Input 输入包含多组数据,格式如下。第一行包括两个整数n m,代表城市个数和可以修建的公路个数。(n 剩下m行每行3个正整数a b c,原创 2017-06-01 22:53:18 · 358 阅读 · 0 评论 -
POJ - 3615 Cow Hurdles (Floyd变形)
Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gang are practicing jumping over hurdles. They are getting tired, though, so they want to be able to use as l原创 2017-08-05 21:23:45 · 428 阅读 · 0 评论 -
Floyd算法(事实证明只会SPFA和Dijkstra还是不够啊)
正如我们所知道的,Floyd算法用于求最短路径。Floyd算法可以说是Warshall算法的扩展,三个for循环就可以解决问题,所以它的时间复杂度为O(n^3)。Floyd算法的基本思想如下:从任意节点A到任意节点B的最短路径不外乎2种可能,1是直接从A到B,2是从A经过若干个节点X到B。所以,我们假设Dis(AB)为节点A到节点B的最短路径的距离,对于每一个节点X,我们检查Dis(AX) +转载 2017-07-27 09:38:06 · 433 阅读 · 0 评论 -
POJ - 2240 Arbitrage(SPFA判断正环| 前向星+SPFA尝试)
Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British原创 2017-08-04 11:28:34 · 476 阅读 · 0 评论 -
tarjan 算法(求强连通分量)
全网最详细tarjan算法讲解,我不敢说别的。反正其他tarjan算法讲解,我看了半天才看懂。我写的这个,读完一遍,发现原来tarjan这么简单!tarjan算法,一个关于 图的联通性的神奇算法。基于DFS(迪法师)算法,深度优先搜索一张有向图。!注意!是有向图。根据树,堆栈,打标记等种种神(che)奇(dan)方法来完成剖析一个图的工作。而图的联通性,就是任督二脉通不通。。的问题。了解t转载 2017-07-26 10:14:02 · 443 阅读 · 0 评论 -
UVALive - 6039 Let's Go Green
There are a lot of cities in Tree Land kingdom and each city is connected to other cities with roads such that there is exists exactly one path to go from one city to any other city. Each road in Tree原创 2017-07-26 09:31:33 · 568 阅读 · 0 评论 -
POJ - 3660 Cow Contest (Warshall算法求传递闭包)
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is uni原创 2017-08-03 08:41:51 · 565 阅读 · 0 评论 -
POJ - 3259 Wormholes(SPFA最短路判断负环)
While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that is原创 2017-08-03 08:32:10 · 769 阅读 · 0 评论 -
POJ - 1860 Currency Exchange(SPFA最大路判断正环)
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can原创 2017-08-02 21:27:08 · 474 阅读 · 0 评论 -
对SPFA算法的一些补充结论
SPFA算法有两个优化算法 SLF 和 LLL: SLF:Small Label First 策略,设要加入的节点是j,队首元素为i,若dist(j)否则插入队尾。 LLL:Large Label Last 策略,设队首元素为i,队列中所有dist值的平均值为x,若dist(i)>x则将i插入 判断有无负环:如果某个点进入队列的次数超过V次则存在负环(SPFA无法处理带负环的图)原创 2017-08-02 19:23:02 · 337 阅读 · 0 评论 -
Roads and Libraries(最小生成树)
The Ruler of HackerLand believes that every citizen of the country should have access to a library. Unfortunately, HackerLand was hit by a tornado that destroyed all of its libraries and obstructed it原创 2017-06-19 09:06:43 · 549 阅读 · 0 评论 -
SDUT 3363 数据结构实验之图论七:驴友计划(最短路)
Problem Description做为一个资深驴友,小新有一张珍藏的自驾游线路图,图上详细的标注了全国各个城市之间的高速公路距离和公路收费情况,现在请你编写一个程序,找出一条出发地到目的地之间的最短路径,如果有多条路径最短,则输出过路费最少的一条路径。Input连续T组数据输入,每组输入数据的第一行给出四个正整数N,M,s,d,其中N(2 Output原创 2017-06-01 22:36:31 · 397 阅读 · 0 评论 -
FZU - 2254 英语考试(最小生成树)
在过三个礼拜,YellowStar有一场专业英语考试,因此它必须着手开始复习。这天,YellowStar准备了n个需要背的单词,每个单词的长度均为m。YellowSatr准备采用联想记忆法来背诵这n个单词:1、如果YellowStar凭空背下一个新词T,需要消耗单词长度m的精力2、如果YellowSatr之前已经背诵了一些单词,它可以选择其中一个单词Si,然后通过联想记忆的方法去背诵新词T,需要消耗原创 2017-07-25 09:40:37 · 571 阅读 · 0 评论 -
SDUT 2622 最短路径
最短路径Time Limit: 1000MS Memory Limit: 65536KBSubmit Statistic DiscussProblem Description为了准备一年一度的校赛,大家都在忙着往赛场搬运东西,比如气球什么的。这时 YY 也没有闲着,他也加入了搬运工的行列。已知学校有 N 个路口和 M 条路,YY 并不是把东西直接搬到赛场,而是从 S 路口搬运到原创 2017-06-03 00:18:47 · 383 阅读 · 0 评论 -
UVa 12507 - Kingdoms(状压dp)
A kingdom has n cities numbered 1 to n, and some bidirectional roads connecting cities. The capitalis always city 1.After a war, all the roads of the kingdom are destroyed. The king wants to rebui原创 2017-06-27 12:30:32 · 460 阅读 · 0 评论
分享