=======markdown
*奇环树:找出环,断边变树;;或者分两部分
环网络
struct Edge{ int from,to,dist; Edge(){} //??要写构造函数? }
不写了。;。学习
*Prim:
千万不要写register。inline还行code
priority_queue<pair<int,int>, vector<pair<int,int> >,greater<pair <int,int> > > int prim(){ int ans=0; q.push(make_pair(0,1)) }
https://www.luogu.com.cn/problem/P1265
https://www.luogu.com.cn/problem/P5687
货车运输:最小权值最大
?
灾后重建 https://www.luogu.com.cn/problem/P1119
物流运输 https://www.luogu.com.cn/problem/P1772
最优贸易 https://www.luogu.com.cn/problem/P1073
逛公园 https://www.luogu.com.cn/problem/P3953 :分层图,额外花费=w-(d[j]-d[i])分的层(DAG)
Legacy https://www.luogu.com.cn/problem/CF786B 区间最短路
今晚搞一搞线段树呗get
A终点未被访问过,树枝边
B终点被访问过,dfn[v]>dfnu,前向边(
C终点已被访问过,不在子树中,在栈中,后向边
D终点被访问过,且不在子树中,不在栈中,横叉边(it
*Tarjan
有向有环图DFS找每个强连通份量
每个强连通份量高度最低的点做表明点(分割点)
(每个强联通份量的点必定连续访问)
分割的方法:维护一个栈(并不是DFS的栈)存放节点,离开分割点时把分割点往下的部分所有取出来就是一个强连通份量
如今须要找到这些分割点:::
。。。。。。。。。
我学废了。晚上先搞tarjan吧io
void tarjan(int now){ dfn[low]=low[now]=++dfscnt; s[stop++]=now; for(int i=he[how];i;i=ne[i]){ if(!dfn[ed[i]]){ tarjan(ed[i]); low[now]=min(low[now],low[ed[i]]); } else if(!) } }
//抄啥,他会发的;__;
模板:
https://www.luogu.com.cn/problem/P3387模板
校园网
https://www.luogu.com.cn/problem/P2746
至少把出度为零的点(t个)加上边,连到入口点,总能构造一个环;
须要链接max(出口点数,入口点数)个边。因此必定存在这个方案。只需求出数目。class
双连通份量
在无向图上。点双联通,边双联通。
不双联通的话,割点(顶),割边(桥)通常就考这个。缩完是一棵树,很差考。
点双联通不知足传递性,边双联通知足。
点双联通必定是边双联通(无相同点的两条路景必定无相同边)
.....懵。.。.
换教室P1850(hard)
提升组范围内,很难玩出什么花,顶可能是分层图。。本质是多保存几个状态。 (进一步学习网络流以后思惟难度才会提高