【模板】链式前向星+spfa


洛谷传送门——分糖果

博客——链式前向星

团队中一道题,数据很大,只能用链式前向星存储,spfa求单源最短路。

可做模板。

#include <cstdio> #include <queue> #include <cstring> #include <algorithm> using namespace std; int n, p, c, ans, cnt; long long m; struct node edge[5000001]; int dis[5000001], head[500001], x, y; bool vis[5000001]; void spfa() } } } int main() spfa(); for(i = 1; i <= n; i++) ans = max(ans, dis[i]); printf("%lld", ans + m); return 0; } 复制代码
View Code



上一篇:【模板】最小费用最大流

下一篇:IDEA 默认模板使用


spfa 最短路 模板
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图