![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
最短路
mmk27
这个作者很懒,什么都没留下…
展开
-
poj2449 Remmarguts' Date 第k最短路
"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story. "Prince Remmarguts lives in his kingdom UDF – ...原创 2018-09-13 11:47:16 · 148 阅读 · 0 评论 -
2019牛客暑期多校训练营(第四场)J free 最短路+dp
题目链接:https://ac.nowcoder.com/acm/contest/884/J 题意:n个点,m条边,起初选取k条边的权值变为0,求S到T的最短路 题解:dp[i][j] 表示到i这个点,选了j条边的权值为0的最短距离,然后对于每条边要么变为0,要么不变,这个题的数据水了,很多不对的方法也过了。。。。 #include <bits/stdc++.h> using ...原创 2019-07-28 11:20:14 · 401 阅读 · 0 评论 -
Contest1802 - 2019年第二阶段我要变强个人训练赛第十八场 问题 F: 路 最短路+枚举边
题目链接:http://icpc.upc.edu.cn/problem.php?cid=1802&pid=5 问题 F: 路 时间限制:1 Sec内存限制:128 MB 提交:198解决:49 [提交] [状态] [命题人:admin] 题目描述 Farmer John 热衷于散步,每天早上他都要从 1 号仓库走到 n 号仓库。 Farmer John 家的 n 个...原创 2019-07-30 18:43:27 · 217 阅读 · 0 评论 -
HDU - 5889 Barricade 最短路+最小割
题目链接:https://cn.vjudge.net/problem/HDU-5889 题解:这个题在最大流的情况只出现在最短路,所以先跑一遍最短路,找出限制的边,跑一边最大流即可,要用上当前弧优化。 #include<iostream> #include<cstdio> #include<queue> #include<cstring> #d...原创 2019-07-09 13:24:21 · 251 阅读 · 0 评论 -
Contest1790 - 2019年第二阶段我要变强个人训练赛第十二场 问题 I: 连边 建源点+求最短路的总路径
题目描述 给出一幅由 n 个点 m 条边构成的无向带权图。其中有些点是黑点,另外点是白点。 现在每个白点都要与他距离最近的黑点通过最短路连接(如果有很多个,可以选取其中任意一个),我们想要使得选出的边花费的代价最小。请问这个最小代价是多少? 注意:最后选出的边须保证每个白点到黑点的距离仍然是最短距离。 输入 第一行两个整数n,m 第二行n个整数,0表示白点,1表示黑点 接下来m行,每行...原创 2019-07-08 10:37:56 · 208 阅读 · 0 评论 -
HDU - 4856 Tunnels 最短路bfs+状压dp
题目链接:点击查看 题意:n*n的图,给出m个隧道的起点和终点,问经过所有隧道所需要的最小时间,在隧道内不花时间,每个隧道只能走一次 题解:先预处理出每个隧道的终点到其他隧道的起点的最小距离,因为隧道只有15个,然后状压一下就可以了,主要要记录一个隧道的终点到其他的起点,因为起点或终点有可能会有一样的,我刚开始记录成终点到终点了,但是对于终点一样,起点不一样的隧道来说就会有多个值,就没法搞了,...原创 2019-04-19 13:32:34 · 130 阅读 · 0 评论 -
CodeChef - CLIQUED Bear and Clique Distances 最短路+部分完全图+建虚点
题目链接:点击查看 题意:n的点,前k个点组成一个完全图,距离为x,然后给出m条边,求s到所有点的最短路 题解:当遇到一个小于等于k的点时,枚举1-k的点更新一下,后面再遇到1-k的点时就不会更新了,所以更新过一次后标记一下即可 另一种思路就是在设一个点,1-k的点到他就是0,他到1-k就是x,这样也是只更新一遍 #include<bits/stdc++.h> usin...原创 2019-04-02 23:18:50 · 135 阅读 · 0 评论 -
CSL 的训练计划 二分+最短路
链接:https://ac.nowcoder.com/acm/contest/551/G 来源:牛客网 题目描述 众所周知,CSL 是一个负责的集训队队长。为了让集训队的学弟们训练更加饱和,他根据每个人的能力,提出了 m 个题数要求。假如 CSL 认为 yiyi 比 xixi 强,那么如果 xixi 做了 a 题,那 CSL 会要求 yiyi 需要做至少 a+ri×ka+ri×k,其中 r...原创 2019-04-01 14:29:39 · 367 阅读 · 0 评论 -
CodeForces - 938D Buy a Ticket 建源点
题目链接:点击查看 题意:n个城市,m条路,每条路都有自己的花费,每个城市看演唱会也有自己的花费,问从每一个城市到另一个城市(或就在自己城市)看演唱会的最小花费,到其他城市看完再回来。 题解:建一个源点,源点到其他点的距离就为该城市的演唱会的门票话费,从原点跑一边最短路即可,细想一下,太强了 #include<bits/stdc++.h> using namespace std...原创 2019-03-23 20:15:19 · 124 阅读 · 0 评论 -
CodeForces - 545E Paths and Trees 最短路建树
题目链接:点击查看 Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important than solving problems, but she found this problem too interesting, so she wanted...原创 2019-02-27 13:57:30 · 273 阅读 · 0 评论 -
POJ - 4046 Sightseeing 暴力枚举下的SPFA
题目链接:点击查看 题意:给一个图和q个询问,每个询问查询图中两点的(距离+路径上最大值)的最小值。 题解:暴力枚举每个点,以这个点为起点并且为路径上所有经过的点的价值中最大的点来跑最短路,每跑一次,更新下q次询问 #include<iostream> #include<cstdio> #include<algorithm> #include<qu...原创 2018-12-25 20:47:02 · 110 阅读 · 0 评论 -
CodeForces - 500B New Year Permutation floyd+选择排序
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible. Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., ...原创 2018-12-18 21:43:02 · 290 阅读 · 0 评论 -
HDU - 4725 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-11-22 10:00:25 · 180 阅读 · 0 评论 -
CodeForces - 1076D Edge Deletion 最短路标记边
You are given an undirected connected weighted graph consisting of nn vertices and mmedges. Let's denote the length of the shortest path from vertex 11 to vertex ii as didi. You have to erase some ed...原创 2018-11-14 22:28:53 · 266 阅读 · 0 评论 -
UVALive 8266 Network Report Floyd算法
题解:给你几个点和几条边,让你求任意两点之间的最短路,并且自己到达自己的不算,求出路径长度不同的分别有几条 #include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f const int N=210; int dis[N][N],ans[N]; int n,m; int main() { int u,v...原创 2018-11-07 10:45:13 · 112 阅读 · 0 评论 -
CodeForces - 208C Police Station 最短路
The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to n, where the main capital city has number n, and the culture capital — number 1. The road ...原创 2018-10-29 15:29:31 · 181 阅读 · 0 评论 -
2019ccpc网络赛 HDU - 6705 path 贪心跑第k小的路径长度
题目链接:https://vjudge.net/problem/HDU-6705 题解:建立源点 汇点 跑A*,到最后也一直超内存也真是菜到家了,A*时间空间怎么也得n^2,这个题原来是个贪心。。。。 官方题解: 先把每条边以 形式放进堆,堆按路径权值从小到大排序,然后每次取出堆顶,用v的出边扩展 新的路径。但是一个点的出度可能会非常大(如菊花图),可以发现,将出边排序之后,每次只需要扩 展...原创 2019-08-24 13:03:07 · 278 阅读 · 0 评论