![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
最短路
lp_opai
我没有时间写一封简短的信,所以我写了一封长的。
展开
-
hdu 2680 Choose the best route (dijkstra)
/* 求点与点之间最短距离。因为此题的起始点不定, 所以可用反向图来求得,终点确定,从终点出发 */ # include # include # include using namespace std; # define INF 10000010 int map[2010][2010]; int dis[2010]; int vis[2010]; int n; void dijkstra(i原创 2015-08-10 19:15:10 · 385 阅读 · 0 评论 -
hdu 1595 find the longest of the shortest (dijkstra)
/* 假设图中某条路径被堵死,它的最坏情况下的最短路径是多少? 基本算法就是先求出最短路径,然后假设最短路径中的某一条边被堵死, 再求最短路,取这些最短路的最大值即可。 */ # include # include # include using namespace std; # define inf 100000000 int dis[1010]; int map[1010][1010]; in原创 2015-08-31 19:44:35 · 477 阅读 · 0 评论 -
poj 3259 Wormholes (bellman_ford)
/* John的农场里N块地,M条路连接两块地,W个虫洞,虫洞是一条单向路, 会在你离开之前把你传送到目的地,就是当你过去的时候时间会倒退Ts。 我们的任务是知道会不会在从某块地出发后又回来,看到了离开之前的自己。 简化下,就是看图中有没有负权环。有的话就是可以,没有的话就是不可以了。 */ # include # include # include using namesp原创 2015-09-03 20:35:56 · 355 阅读 · 0 评论 -
poj1860 Currency Exchange (bellman_ford)
/* 有多种汇币,汇币之间可以交换,这需要手续费 货币的交换是可以重复多次的,所以我们需要找出是否存在正权回路,且最后得到的s金额是增加的 怎么找正权回路呢?(正权回路:在这一回路上,顶点的权值能不断增加即能一直进行松弛) */ # include # include # include using namespace std; struct node { int u; i原创 2015-09-02 22:01:09 · 411 阅读 · 0 评论