
最短路
追逐星辰的光
脚踏实地,虚心前行
展开
-
HDU 4725 The Shortest Path in Nya Graph
This is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algoritmo. If you do not understand a word of this paragraph, just原创 2018-01-21 13:32:21 · 257 阅读 · 0 评论 -
最短路问题之单源最短路-Dijkstra算法
一个点(源点)到其余各个顶点的最短路径,叫做单源最短路经。例如求下图中的1号顶点到2,3,4,5,6号顶点的最短路径。使用二维数组e来存储顶点之间边的关系,初始值如下表。e12345610112infinfinf2inf原创 2018-01-19 21:56:32 · 494 阅读 · 0 评论 -
POJ 3159 Candies
During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the原创 2018-01-20 15:13:27 · 305 阅读 · 0 评论 -
POJ 3169 Layout
Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The cows are standin原创 2018-01-20 16:39:57 · 384 阅读 · 0 评论 -
POJ 1511 Invitation Cards
In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They原创 2018-01-19 23:13:26 · 246 阅读 · 0 评论 -
POJ 2253 Frogger
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原创 2018-01-15 08:31:26 · 263 阅读 · 0 评论 -
LightOJ 1074 Extended Traffic
Dhaka city is getting crowded and noisy day by day. Certain roads always remain blocked in congestion. In order to convince people avoid shortest routes, and hence the crowded roads, to reach destinat原创 2018-01-20 21:03:52 · 380 阅读 · 0 评论 -
2018 蓝桥杯省赛 B 组模拟赛(一)--- H. 封印之门
蒜头君被暗黑军团包围在一座岛上,所有通往近卫军团的路都有暗黑军团把手。幸运的是,小岛上有一扇上古之神打造的封印之门,可以通往近卫军团,传闻至今没有人能解除封印。封印之门上有一串文字,只包含小写字母,有 k种操作规则,每个规则可以把一个字符变换成另外一个字符。经过任意多次操作以后,最后如果能把封印之门上的文字变换成解开封印之门的文字,封印之门将会开启。蒜头君战斗力超强,但是不擅计算,请你帮忙蒜头君计...原创 2018-03-09 20:23:23 · 840 阅读 · 0 评论 -
POJ 1062 昂贵的聘礼
中文题,就不贴题了。一开始想一发过,记录交换的最小等级和最大等级,才知道并没有这么简单,因为这个等级限制是不是只限于当前交换的两个人,而是交换的所有人,最后实在想不起来什么好办法,就在网上发现采用枚举,即假设酋长等级为5,等级限制为2,那么需要枚举等级从3~5,4~6,5~7,然后注意就是是单向路径,一开始以为枚举会超时,其实想多了,很快就过了。#include #include #inclu原创 2018-01-18 19:47:35 · 287 阅读 · 0 评论 -
POJ 1847 Tram
题意:问从起点到终点至少转弯几次第一行输入:N, A, B :N代表N个点,A代表起始点, B代表终点接下来有N行(每行代表第几个点)输入第一行:K Ki... :K表示右边接下来有K个点(用Ki表示)第一个点与1直接相连,接下来的点与1间接相连(需要转弯一次)第二行:K Ki... :同上,右边有K个点, 第一个点与2相连,接下来的点与2也相连,只不原创 2018-01-18 18:33:01 · 220 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b原创 2018-01-13 18:15:02 · 181 阅读 · 0 评论 -
POJ 1797 Heavy Transportation
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 cu原创 2018-01-15 10:31:56 · 214 阅读 · 0 评论 -
POJ 3268 Silver Cow Party
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 #X (1 ≤ X ≤ N). A total of M (1 ≤ M≤ 100,000) unidirectional (one-way r原创 2018-01-15 15:11:07 · 207 阅读 · 0 评论 -
POJ 1860 Currency Exchange
我们的城市有几个货币兑换点。让我们假设每一个点都只能兑换专门的两种货币。可以有几个点,专门从事相同货币兑换。每个点都有自己的汇率,外汇汇率的A到B是B的数量你1A。同时各交换点有一些佣金,你要为你的交换操作的总和。在来源货币中总是收取佣金。 例如,如果你想换100美元到俄罗斯卢布兑换点,那里的汇率是29.75,而佣金是0.39,你会得到(100 - 0.39)×29.75=2963.3975卢布。原创 2018-01-15 19:08:20 · 285 阅读 · 0 评论 -
POJ 3259 Wormholes
虫洞是很奇特的,因为它是一个**单向**通道,可让你进入虫洞的前达到目的地!他的N(1≤N≤500)个农场被编号为1..N,之间有M(1≤M≤2500)条路径,W(1≤W≤200)个虫洞。FJ作为一个狂热的时间旅行的爱好者,他要做到以下几点:开始在一个区域,通过一些路径和虫洞旅行,他要回到最开时出发的那个区域出发前的时间。也许他就能遇到自己了:)。为了帮助FJ找出这是否是可以或不可以,他会为你提供原创 2018-01-15 20:43:20 · 286 阅读 · 0 评论 -
POJ 1502 MPI Maelstrom
题目链接:https://vjudge.net/problem/POJ-1502题很简单,就是阅读起来有点麻烦,我解释一下样例就可以了,普通的最短路,很容易。Sample Input5 表示有5个点 (路径都是双向的)50 1和2相关联,路径长度为5030原创 2018-01-16 13:45:42 · 275 阅读 · 0 评论 -
POJ 3660 Cow Contest
有n(1给出m条实力信息。(1其中每一条的格式为 A B (1如果A比B强且B比C强,那么A一定比C强。问最后有多少名学生可以确定他的排名。保证输入信息不存在矛盾Input 第一行n和m。以下m行 A B 表示A实力比B强。Output输出答案 Sample Input5 54 34 23 21 22 5Sam原创 2018-01-17 16:37:55 · 262 阅读 · 0 评论 -
POJ 2240 Arbitrage
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 Britis原创 2018-01-17 17:21:30 · 243 阅读 · 0 评论 -
POJ 2502 Subway
You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway. Because you don't want原创 2018-01-18 10:03:31 · 316 阅读 · 0 评论 -
Floyd-Warshall算法
Floyd算法是求解任意两点之间的最短路的算法(多源最短路问题)。它的代码长度很短,只有五行,可是算法复杂度很高,可以在O(|n^3|)时间里求得所有两点间的最短路长度,所以对于三位数一下的最短路题目,可以考虑使用Floyd算法,简单实用。Floyd也可以处理负数的情况,而且可以判断图中是否有负图。 小哼准备去几个城市去旅游,有些城市之间有公路,有些城市之间没有,如下图,为了节省花费以及方便计划...原创 2018-03-03 12:52:33 · 696 阅读 · 0 评论