![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论
护理系程序猿
这个作者很懒,什么都没留下…
展开
-
网络流总结
网络流原创 2022-08-08 11:08:13 · 106 阅读 · 0 评论 -
SPFA优化(SLF+LLL)
SPFA优化(SLF+LLL)转载 2022-07-30 11:54:56 · 91 阅读 · 0 评论 -
求树的直径
两遍dfs#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=100005;int n,m,t,p,ans;int d[N],first[N],v[N],w[N],next[N];void add(int x,int y,int z){ t++; next[t]=first[x]; first[x]=t; v[t]=y; w[t]转载 2022-04-10 18:32:43 · 52 阅读 · 0 评论 -
拓扑图判环
拓扑图判环使用拓扑排序判断无向图和有向图中是否存在环的区别在于:在判断无向图中是否存在环时,是将所有度 <= 1 的结点入队;在判断有向图中是否存在环时,是将所有入度 = 0 的结点入队。...原创 2022-03-19 15:27:58 · 237 阅读 · 0 评论 -
LCA(倍增,Tarjan)
LCA倍增tarjan倍增#include<bits/stdc++.h>//#define max(a,b) (((a) > (b)) ? (a) : (b))using namespace std;int n,T,root,deep[500010],maxdeep,f[500010][25];int tot,h[500010],top;struct node{ int next,to;}e[2*500010];void add(int u,int v){ ++to原创 2022-01-22 23:49:22 · 260 阅读 · 0 评论 -
最小生成树
最小生成树prim#include<bits/stdc++.h>#define inf 1000000000using namespace std;int n,m,dis[5010],ans;bool b[5010];int tot,h[5010],nxt[400010],to[400010],cost[400010];void add(int x,int y,int z){ ++tot; nxt[tot]=h[x]; h[x]=tot; to[tot]=y; cos原创 2022-01-22 17:17:52 · 279 阅读 · 0 评论 -
并查集..
1.核心思想:建立一个具有连通性质的集合2. 实现关键:路径压缩3.初始化:自己的父亲是自己4. 代码#include<bits/stdc++.h>using namespace std;const int nu=500100;struct node{ int u,v,w;}e[nu];int f[nu],p,m,dis,k=0;int getf(int x){ if(x==f[x])return x; else return f[x]=getf(f原创 2022-01-22 16:32:33 · 289 阅读 · 0 评论 -
最短路(3算法)
最短路floyeddijkstraSPFAfloyed核心代码for (i = 1; i <= n; i++){ for (j = 1; j <= n; j++){ if (e[i][j] > e[i][1] + e[1][j]) e[i][j] = e[i][1] + e[1][j]; }}dijkstra不能有负权边堆优化,复杂度O(nlogn)代码#include<bits/stdc++.h&g原创 2022-01-22 12:03:45 · 229 阅读 · 0 评论 -
拓扑排序DAG
拓扑排序适用:有向无环图使用情景:每个项目有自己的前置任务复杂度O{N+E}代码(noip神经网络)#include<queue>#include<cstdio>#include<algorithm>#define N 101using namespace std;struct edge{ int to,val,nxt;} e[N*N];struct answer{ int id,val;} ans[N];int h,i,m,n,t,u原创 2022-01-22 10:44:16 · 158 阅读 · 0 评论