
模版
我的昵称已被注册
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
割点,桥,点、边双连通分量模版
核心是时间戳+dfs 无向图的dfs森林只有树边和反向边 割点: ①根结点为割点当其有至少2个儿子 ②非根结点u为割点当存在子结点v的low[v]>=dfn[u] 桥: 在dfs树中,v是u的儿子,边(u,v)为桥当low[v]>dfn[u] struct E { int to,next,cut; }edge[maxm]; int head[maxn],tol;...原创 2019-01-25 21:24:42 · 244 阅读 · 2 评论 -
强连通分量模版
Kosaraju算法 借助反图获得好的dfs遍历顺序 int bel[maxn],stk[maxn],top,blocks; bool vis[maxn]; vector<int>G1[maxn],G2[maxn]; inline void dfs1(int u) { if(vis[u]) return; vis[u]=1; for(int i=0;i&l...原创 2019-01-25 23:11:10 · 142 阅读 · 0 评论 -
2—SAT模版
2-SAT问题 求解n个布尔变量满足合取范式的解,每个变量两个取值,实际上代表两种状态的选择。 一些建边的技巧 (1)同或建边(x,y),(x^1,y^1),(y,x),(y^1,x^1) (2)异或建边(x,y^1),(x^1,y),(y,x^1),(y^1,x) (3)某些变量固定取值(如x=1),(x^1,x)构造反状态的矛盾即可 dfs染色法求字典序最小的解 stru...原创 2019-01-26 01:10:16 · 144 阅读 · 0 评论 -
费用流模版
基于贪心选择最小费用增广路增广的算法 Spfa费用流 struct E { int to,next,cap,flow,cost; }edge[maxm]; int head[maxn],tol; inline void Addedge(int u,int v,int w,int c) { edge[tol].to=v;edge[tol].cap=w;edge[tol].flo...原创 2019-01-26 22:14:35 · 130 阅读 · 0 评论 -
Splay树模板
#define kw ch[ch[rt][1]][0] const int maxn=500010; const int INF=0x3fffffff; int w[maxn]; struct Splay { int ch[maxn][2],fa[maxn],sz[maxn],key[maxn],rt,tot; int same[maxn],rev[maxn],sum[maxn]...原创 2019-02-01 23:11:11 · 146 阅读 · 0 评论 -
fread快读模版
文章转自https://blog.youkuaiyun.com/xlzhang223/article/details/77619547 struct FastIO { static const int S = 1e7; int wpos; char wbuf[S]; FastIO() : wpos(0) {} inline int xchar() { ...转载 2019-02-07 00:01:15 · 820 阅读 · 0 评论