摘要: #include <bits/stdc++.h> using namespace std; const int N = 550, M = 100010, INF = 0x3f3f3f3f; int g[N][N], dist[N]; // dist存点到(最小生成树的点集合)的最小距离 bool s 阅读全文
posted @ 2020-08-12 21:34 Sexyomaru 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 分析: f[i, j, k]表示从i走到j的路径上除i和j点外只经过1到k的点的所有路径的最短距离。那么f[i, j, k] = min(f[i, j, k - 1), f[i, k, k - 1] + f[k, j, k - 1]。 因此在计算第k层的f[i, j]的时候必须先将第k - 1层的所 阅读全文
posted @ 2020-08-12 20:22 Sexyomaru 阅读(68) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 10010; int h[N], e[N], ne[N], w[N], idx; int dist[N], cnt[N]; bool st[N]; int n, m; void a 阅读全文
posted @ 2020-08-12 20:10 Sexyomaru 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 100010; int h[N], e[N], w[N], ne[N], idx; int dist[N]; bool st[N]; int m, n; void add(int 阅读全文
posted @ 2020-08-12 19:53 Sexyomaru 阅读(108) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 550, M = 10010; struct Edges{int a, b, w;}edges[M]; int dist[N], pre[N]; int m, n, k; int 阅读全文
posted @ 2020-08-12 19:41 Sexyomaru 阅读(95) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 1000010; int h[N], e[N], ne[N], w[N], idx; int dist[N]; bool st[N]; int m, n; void add(int 阅读全文
posted @ 2020-08-12 19:28 Sexyomaru 阅读(115) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 550, M = 10010; int g[N][N], dist[N]; bool st[N]; int m, n; int dijkstra() { memset(dist,0 阅读全文
posted @ 2020-08-12 19:13 Sexyomaru 阅读(120) 评论(0) 推荐(0) 编辑