![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论
lxsshgdl
这个作者很懒,什么都没留下…
展开
-
spfa(fellmen-ford队列优化)
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int MAXN = 1005;const int INF = 0x3f3f3f3f;int n, m, lc[MAXN], cnt[MAXN];//cnt[]为入队列次数bool vis[MAXN];//是否存在队列标志struct原创 2021-02-14 22:45:38 · 100 阅读 · 0 评论 -
fellman-ford
求解带有负权边的图的最短路#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int MAXN = 1005;const int INF = 0x3f3f3f3f;int n, m, lc[MAXN];struct Edge { int u, v, w; Edge(int u, i原创 2021-02-14 21:47:23 · 79 阅读 · 0 评论 -
kruskal
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int INF = 0x3f3f3f3f;const int MAXN = 1006;const int MAXM = 1006;int f[MAXN];int n, m;struct Edge { int u, v, c;}e原创 2021-02-12 11:36:44 · 105 阅读 · 0 评论 -
dijkstra——堆优化
dijkstra——堆优化#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int INF = 0x3f3f3f3f;const int MAXN = 1e6 + 5;struct qNode { //v->当前结点 c->该结点的最短路径 int v, c; qNo原创 2021-02-09 22:10:07 · 130 阅读 · 0 评论 -
floyd
Floyd算法,求从任意节点i到任意节点j的最短路径#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int INF = 0x3f3f3f3f;const int MAXN = 1e3 + 5;//c[][]存储两点间最短路径,初始化为INF,c[i][i]=0int c[MAXN][原创 2021-02-10 14:57:39 · 77 阅读 · 0 评论 -
prim
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int INF = 0x3f3f3f3f;const int MAXN = 1e3 + 5;//先初始化c[][]为INF再输入边权int c[MAXN][MAXN], lc[MAXN];bool vis[MAXN];int pri原创 2021-02-10 16:59:26 · 99 阅读 · 0 评论 -
dijkstra
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(false);cin.tie(0);using namespace std;typedef long long ll;const int MAXN = 1005;const int INF = 0x3f3f3f3f;int c[MAXN][MAXN], vis[MAXN], lc[MAXN], p[MAXN];int n, m;//从start出发void d原创 2021-02-14 20:07:52 · 75 阅读 · 0 评论