随笔分类 -  图论-最短路

摘要:https://www.luogu.com.cn/problem/P4779 \(Code:\) #include<bits/stdc++.h> #define N 100005 #define M 200005 #define INF 2000000000000000 using namespac 阅读全文
posted @ 2020-10-12 16:57 GK0328 阅读(129) 评论(0) 推荐(0)
摘要:https://www.luogu.com.cn/problem/P6772 矩阵乘法/最长路 $NOI2020$唯一在蒟蒻能力范围之内的题目没有$A$掉,\(QAQ\) 考试的时候一看数据范围,矩阵快速幂!一直在考虑拆边,结果发现点数高达$2500+$,然后一直考虑不拆边怎么转移(分类讨论之类的) 阅读全文
posted @ 2020-08-19 18:15 GK0328 阅读(94) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3621 最短路 二分答案$mid$ 令$u \rightarrow v$边权为$mid*cost_{u,v}-val[u]$ 若有负环则满足题意 POJ居然不能用%.lf ,只能用%.f \(Code:\) #include<cstdio> #i 阅读全文
posted @ 2020-08-06 14:46 GK0328 阅读(54) 评论(0) 推荐(0)
摘要:https://www.luogu.com.cn/problem/CF786B 线段树优化建图 对于区间$[l,r]$,可以用线段树中的节点优化建图 对于从外面指向指定区间的边,它只能往下转移 例: 如果存在$v\rightarrow [l,r]$,那么一定存在$v\rightarrow [s,t] 阅读全文
posted @ 2020-07-30 17:34 GK0328 阅读(385) 评论(0) 推荐(0)
摘要:https://www.luogu.com.cn/problem/P5905 Johnson 将源点设为$0$,将$0$向每个点连一条边权为$0$的边 先跑一边$SPFA$ 再将$u\rightarrow v$的一条边的边权增加$dis[u]-dis[v]$ 从每个点开始跑$dijkstra$,求出 阅读全文
posted @ 2020-07-20 18:16 GK0328 阅读(106) 评论(0) 推荐(0)