
最短路
Error Man
我是菜逼
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Marriage Match IV HDU - 3416 (最短路径包含的边 + 最大流)
Marriage Match IV题意:给定一张图,起点 s,终点 t,每条路只能走一次,问从s 到 t 的最短路径有几种思路:先寻找最短路径中的可行边。寻找方法是,先从s 跑一边最短路,记数组为 dis1, 从t 跑一边反向图的最短路,记数组为dis2。对于每一条边,如果 dis1[u] + dis2[v] + w == dis1[t] ,这条边就在最短路径上。。。 对于每一条...原创 2019-01-24 20:34:22 · 249 阅读 · 0 评论 -
最短路模版(优先队列优化,迪杰斯特拉)与spfa
//都可解决有向图,无向图优先队列优化迪杰斯特拉..(权值非负)const int maxn=...; //maxn 为最多的城市(或其他)数量int n,m; //n个城市, m条路径int d[maxn]; //d[i] 表示 某个城市到城市 i 的最短距离vector<pair<int,int&...原创 2018-07-24 11:15:35 · 446 阅读 · 0 评论 -
POJ 2449 第k短路模版题 (dijkstra + A star)
Remmarguts' DateTime Limit:4000MS Memory Limit:65536K Total Submissions:35009 Accepted:9461 Description"Good man never makes girls wait or breaks an appointment!" said the ...原创 2018-07-27 16:17:12 · 501 阅读 · 0 评论 -
如何判断是否存在负权环
用同样的spfa 寻最短路的算法, 在此基础上增加一个 coun 数组, coun[i] 表示对 i 进行的松弛操作的此时 。 如果 coun[i] 达到了n (n为结点的数目) 则含负权环。主要是对 松弛操作的 if() 条件语句的控制int coun[maxn],n;bool spfa(int s){ //s 一般为1 或 0, 看题目所给的编号是...原创 2018-07-28 22:45:19 · 1105 阅读 · 0 评论 -
POJ 3462(最短路 + 次最短路, 路径条数)
题目链接:http://poj.org/problem?id=3463题意:给定一张有向图,以及起点 s 终点 f, 求从 s 到 f 的最短路的路径条数 以及 比最短路径大1 的路径条数 之和思路: 用A*算法,类似求第K短路 来写 超时。就只能求最短路 与 次最短路的路径长度以及 它们各自的条数。求次最短路类似于求次最大值。AC代码:#include<...原创 2018-07-28 09:21:29 · 429 阅读 · 0 评论 -
poj 3013 (最短路)
题目链接:http://poj.org/problem?id=3013题意: 给定一张无向图, 要求建立一棵树, 使建这棵树花费最小。(树根为结点1)具体是: 每个结点都有自己的权值, 每条边有一个 单价(可理解为长度), 构建每条边的花费是 此边的单价 * 所有后代的结点权重之和。如果发现 每个结点的最小花费 = 该节点的权值 * 到根节点的最短距离 , 那么这个题就很简单了。注意,用...原创 2018-07-28 15:14:42 · 400 阅读 · 0 评论 -
poj 3268(关键: 求点到终点的最短路)
题目链接:http://poj.org/problem?id=3268题意: 给定一张有向图以及一个点x,求从每个点到点x的最短距离与点x到每个点的最短距离的和最大关键: 如果知道在存图的时候将图反向存, 然后以点 x 为起点 跑一边dij, 求得的redis[] 数组即原图 每个点到x 的最短距离AC代码:#include<cstdio>#include&...原创 2018-07-28 20:17:33 · 354 阅读 · 0 评论 -
POJ 2240 (判环)
ArbitrageTime Limit:1000MS Memory Limit:65536K Total Submissions:27147 Accepted:11426 DescriptionArbitrage is the use of discrepancies in currency exchange rates to transfo...原创 2018-07-29 23:09:05 · 259 阅读 · 0 评论 -
poj 1860(SPFA 判环)
Currency ExchangeTime Limit:1000MS Memory Limit:30000K Total Submissions:35854 Accepted:13743 DescriptionSeveral currency exchange points are working in our city. Let us su...原创 2018-07-30 09:27:05 · 529 阅读 · 0 评论 -
HDU - 5521 Meeting (最短路 ,技巧建图)
MeetingBessie and her friend Elsie decide to have a meeting. However, after Farmer John decorated hisfences they were separated into different blocks. John's farm are divided intonnblocks labell...原创 2018-10-16 15:11:24 · 288 阅读 · 0 评论 -
Extended Traffic LightOJ - 1074 (负权值,SPFA)
Extended TrafficDhaka 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,...原创 2019-01-21 22:16:45 · 157 阅读 · 0 评论 -
HDU - 4725 The Shortest Path in Nya Graph (技巧建图)
The Shortest Path in Nya GraphThis 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...原创 2019-01-22 20:38:11 · 325 阅读 · 0 评论 -
ACM-ICPC 2018 南京赛区网络预赛 Magical Girl Haze(分层图最短路)
Magical Girl HazeThere areNNcities in the country, andMMdirectional roads fromuutov(1\le u, v\le n)v(1≤u,v≤n). Every road has a distancec_ici. Haze is a Magical Girl that lives in City11, ...原创 2019-07-27 20:42:09 · 220 阅读 · 0 评论