bfs及最短路径
Max_1_
这个作者很懒,什么都没留下…
展开
-
2019ICPC银川区域赛-H.Delivery Route( spfa优化 或 强连通分量+拓排+dij)
题目大意:给一个n个点,x条双向边,y条单向边的图,同时双向边权全为正,单向边权有可能为负,且保证单向边不会出现在环中。求从点s分别到1~ n的最短距离。 由于有负边,不能直接用dij,而裸的spfa又会被卡上天,所以需要考虑下其它做法。 强连通分量+拓排+dij。由于负权边不会出现在环中,所以可对图进行缩点,对每个强连通分量跑一遍dij,同时按拓扑序更新后面强连通...原创 2019-11-30 21:15:57 · 1085 阅读 · 6 评论 -
codeforce 877D 路径查找
思路:bfs找最短路。。。加一个for(i=1to k) 的循环便可枚举每一速度,进而可确定后一状态 #include #include #include using namespace std; struct Q{ int x; int y; }u,v; queueq; char s[1005][1005]; int dp[1005][1005],n,m,k,i,j,a,b,c,d; in原创 2017-12-22 13:06:59 · 184 阅读 · 0 评论 -
Prime path
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter of原创 2018-01-27 16:00:41 · 263 阅读 · 0 评论 -
bfs应用最短路径查找--三道基础题
用BFS找最短路的基本思路为每次搜索到一个点或状态判断是否可以更新该点的最小值,若可以则放进队列中去。。。 下面这三道题目都是用BFS求最短路径的 题目1: Farmer John has been informed of the location of a fugitive cow and wants to catch her immediate原创 2018-01-27 16:51:57 · 1270 阅读 · 2 评论 -
csuoj2112(二分,bfs)
题目大意:给n*n的网格,起点S和终点T,网格中会包含一些着火点,每秒向四周蔓延,每秒的最大移动步数为k,输出可在起点停 留的最大时间 思路分析:先预处理出所有点的最短着火时间,二分时间,bfs求出到达每个点的最短路程dp[i][j],通过dp[i][j]/k是否小于着火时间,判断是否能到达这个点。 代码: #include<iostream> #include&...原创 2018-07-25 08:45:31 · 135 阅读 · 0 评论