洛谷传送门——分糖果
博客——链式前向星
团队中一道题,数据很大,只能用链式前向星存储,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
上一篇:拷贝完hadoop集群后如何恢复网络
下一篇:doris单机安装部署
模板 最短路 spfa









