
最短路
西瓜不甜不甜不甜
这个作者很懒,什么都没留下…
展开
-
【POJ】3259 - Wormholes
http://poj.org/problem?id=3259农夫约翰有F个农场,每个农场有N块地,其间有M条路,W条时光隧道(时间倒流)。问是否可能回到过去?spfa判负环。某点入队次数≥总点数#include <iostream>#include <vector>#include <queue>#include <cstring>using namespace std;const int原创 2017-08-22 22:11:12 · 308 阅读 · 0 评论 -
【POJ】3268 - Silver Cow Party
http://poj.org/problem?id=3268N 个农场的 N 头牛去农场 X 嗨皮,M 条有向路径。 每头牛来回都挑最短的路走,求它们走的路的最大长度?做两次spfa。 然后逐个点进行统计。#include <iostream>#include <algorithm>#include <cstring>#include <queue>using namespace std原创 2017-08-22 22:44:31 · 186 阅读 · 0 评论 -
【POJ】2139 - Six Degrees of Cowvin Bacon
http://poj.org/problem?id=2139N头牛,拍了M部电影,同一部电影中的搭档们距离1,求其中一头牛与其他牛关系路程之和sum最小,输出 sum*100/(n-1)floyd。 注意: inf不能太大,因为 f[i][k] + f[k][j] 做加法时可能会溢出!#include <iostream>#include <cstdio>#include <cstring>原创 2017-08-22 22:06:58 · 224 阅读 · 0 评论 -
【POJ】3662 - Telephone Lines 二分+最短路
http://poj.org/problem?id=3662一共有N个电线杆,有P对电线杆是可以连接的,现要使得杆1和杆N相连,K条电线可以免费使用的,当使用电线的数量超过K条,超出的电线要收费,收的总费用为去掉免费使用的K条电线之后最长的那条电线的长度。现在需要尽可能的减少费用,问最少费用是多少。解题思路:可以二分搜索出所需费用,这样,对于每一个最小费用‘候选人’,都要进行判定是否符合题目条件,换原创 2017-08-28 22:19:47 · 473 阅读 · 0 评论 -
L2-001. 紧急救援 dijkstra,适合模版
https://www.patest.cn/contests/gplt/L2-001dijkstra,在求最短路的基础上增加了权值,权值越大越好。#include <bits/stdc++.h>using namespace std;const int maxn=505;const int INF=0x3f3f3f3f;int n,m,st,ed;int G[ma...原创 2018-03-12 14:03:55 · 837 阅读 · 0 评论 -
算法提高 道路和航路 【SPFA+SLF优化】
http://lx.lanqiao.cn/problem.page?gpid=T22#include <bits/stdc++.h>using namespace std;const int maxn=150005;const int INF=1<<30;struct Edge{ int to,next,val;}e[maxn];int N,M...原创 2018-05-03 10:05:58 · 386 阅读 · 0 评论