
最短路
几许情愁
这个作者很懒,什么都没留下…
展开
-
Silver Cow Party
Silver Cow PartyOne 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) unidirectio...原创 2018-04-13 11:02:36 · 105 阅读 · 0 评论 -
洛谷 P1993 小K的农场 【差分约束+spaf】
题目链接:https://www.luogu.org/problem/P1993;首先差分约束系统主要是建图方面,举个例子: ①A - B >= 3 ②B - C >= 2 ...原创 2019-08-09 14:48:32 · 205 阅读 · 0 评论 -
hdu 6582 19 航电多校第一场1005题 path 【最短路+最小割】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6582/*思路:最短路径构成的图的最小割(即最大流)最短路径图:spaf得到 1 到所有点的单源最短路(dis),再求出 n 到所有点的单源最短路(dis1)遍历每条路,设当前边起点为 u ,终点为 v ,圈主为 w , 如果 dis[u]+dis1[v]+w==1到n的最短路径那么...原创 2019-07-26 17:14:05 · 188 阅读 · 0 评论 -
洛谷 P1462 通往奥格瑞玛的道路【二分+最短路spaf】
题目链接:https://www.luogu.org/problem/P1462;/*二分+最短路让求最大值最小,可以直接二分每个点的收费,把比当前点收费高的不能经过,跑一边最短路判断是否可以到达终点*/#include<stdio.h>#include<string.h>#include<algorithm>#include<ios...原创 2019-08-03 09:19:44 · 284 阅读 · 0 评论 -
【最短路 spaf】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 s...原创 2018-06-08 17:53:56 · 218 阅读 · 0 评论 -
【最短路 spaf】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-06-08 17:21:47 · 241 阅读 · 0 评论 -
【最短路 spaf判断负环】O - 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-06-08 11:33:40 · 304 阅读 · 0 评论 -
Cow 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 un...原创 2018-04-27 16:30:26 · 130 阅读 · 0 评论 -
LightOJ 1002
I am going to my home. There are many cities and many bi-directional roads between them. The cities are numbered from0 to n-1 and each road has a cost. There are m roads. You are given the number of m...原创 2018-04-20 10:38:21 · 200 阅读 · 0 评论 -
Bellman-Ford算法模板
三个大致步骤:第一,初始化所有点。每一个点保存一个值,表示从原点到达这个点的距离,将原点的值设为0,其它的点的值设为无穷大(表示不可达)。第二,进行循环,循环下标为从1到n-1(n等于图中点的个数)。在循环内部,遍历所有的边,进行松弛计算。第三,遍历途中所有的边(edge(u,v)),判断是否存在这样情况:d(v) > d (u) + w(u,v)则返回false,表示途中存在从源点可达的权...转载 2018-04-18 20:02:40 · 371 阅读 · 0 评论 -
洛谷 P3119 草鉴定Grass Cownoisseur【强连通缩点+最长路】
题目链接:https://www.luogu.org/problem/P3119;/*首先我们可以通过缩点将一个强连通分量里的所有点变成一个点,并且可以知道缩点以后的图是没有环的,此时我们记缩点以后以一号点在第start个强连通分量里;然后用spaf得出以start到其他点(缩点以后的点)的最长路dis1[],然后用反向的路在得到所有点到start的最长路dis2[],最后我们可以遍...原创 2019-08-20 09:32:31 · 205 阅读 · 0 评论