最短路
最短路
dreambyday
我大抵是病了,
横竖都写不出一行代码。
站起身来点起了一支烟,
这悲伤没有由来。
默默然跑到楼下买了根82年老冰棍,
一口是我吃的,
另一口也是我吃的,
大抵又是到了摸鱼的时刻了吧。
展开
-
POJ1062昂贵的聘礼 枚举最短路spfa
网址:http://poj.org/problem?id=1062 首先是建图。以编号0为搜索起点,以酋长物品(编号1)为终点求最短路。编号0到任意一个点的边权值为该物品原本的价值。非零点之间的权值为优惠后的价格。 因为有等级限制,所以有的点没办法经过。所以要假设一个等级为最小的等级,枚举这些最小等级,枚举后最小的长度就是结果。 我用的spfa方法#include<iostream>#inc原创 2017-05-30 13:57:06 · 471 阅读 · 0 评论 -
LightOJ - 1074Extended 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 destinati原创 2017-09-02 09:20:59 · 161 阅读 · 0 评论 -
HDU - 4370 0 or 1最短路
/*Given a n*n matrix C ij (1<=i,j<=n),We want to find a n*n matrix X ij (1<=i,j<=n),which is 0 or 1. Besides,X ij meets the following conditions: 1.X 12+X 13+...X 1n=1 2.X 1n+X 2n+...X n-1n=1 3.for e原创 2017-09-01 18:26:12 · 207 阅读 · 0 评论 -
POJ - 1511Invitation 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 h原创 2017-08-29 22:44:00 · 232 阅读 · 0 评论 -
POJ - 2240Arbitrage
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-28 19:57:22 · 242 阅读 · 0 评论 -
POJ - 3660Cow Contest
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 u原创 2017-08-28 17:57:28 · 265 阅读 · 0 评论 -
POJ - 1502MPI Maelstrom
BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee’s research advis原创 2017-08-28 17:06:07 · 202 阅读 · 0 评论 -
POJ 3059 Wormholes
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-02-06 14:20:20 · 311 阅读 · 0 评论 -
poj1860Currency Exchange
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-27 19:24:04 · 162 阅读 · 0 评论 -
POJ - 2502Subway
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 t原创 2017-09-04 17:53:21 · 282 阅读 · 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’ suns原创 2017-08-15 20:09:42 · 141 阅读 · 0 评论 -
整理《挑战程序设计竞赛》中最短路的代码
一.Bellman-Ford 核心公式: d[i]=min(d[j]+e.cost,d[i]) 释: d[i]:i节点到源点的当前最短距离 e.cost:相邻两节点的距离(公式中的为j节点指向i节点的距离) 原因: (图片来自百度百科) 这里假设B1为i节点,则A123可以为j节点。d[j]为确定的 j到源点最短距离。此时肯定是比较A123的距离加上i,j的距离之和的最短距离。这个最原创 2017-08-12 19:34:30 · 944 阅读 · 0 评论 -
POJ2387 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 ba原创 2017-08-12 17:17:56 · 206 阅读 · 0 评论 -
POJ3268Silver Cow Party
题意:给出n个点和m条边,接着是m条边,代表从牛a到牛b需要花费c时间,现在所有牛要到牛x那里去参加聚会,并且所有牛参加聚会后还要回来,给你牛x,除了牛x之外的牛,他们都有一个参加聚会并且回来的最短时间,从这些最短时间里找出一个最大值输出 用dijkstra求一次从x出发到所有点的最短距离,然后将所有边反向再求一次从x出发到所有点距离,相加求最大。#include<iostream>#inclu原创 2017-08-17 18:30:34 · 157 阅读 · 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 cus原创 2017-08-16 19:21:03 · 224 阅读 · 0 评论 -
HDU - 4725The 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 m原创 2017-09-03 12:46:29 · 228 阅读 · 0 评论