此页面存在相关页面。关于另一个集合贴,请参见
「OI模板梳理」。
此页面中的索引截至 2020.1.24,其中的某些条目可能已经失效。
文化课真好系列。
为了证明 bn 还没入坟,他决定闲的没事瞎bb几句。
所以他对之前的 post 们搞了一个整理,以备后人之用自己欣赏。
图论
最短路
树
连通性
网络
二分图
欧拉图:欧拉路
x 1#include2#include3#include4#include5using namespace std;67const int CN = 6e5+5;89int read(){10 int s = 0,ne = 1; char c = getchar();11 while(c < ‘0’ || c > ‘9’) ne = c == ‘-‘ ? -1 : 1, c = getchar();12 while(c >= ‘0’ && c <= ‘9’) s = (s << 1) + (s << 3) + c - ‘0’, c = getchar();13 return s * ne;14}1516class fs {public: int to,nxt; void init(int t,int n) {to = t, nxt = n;}}E[CN << 2];17int hd[CN],ecnt = 0; void add(int x,int y) {E[++ecnt].init(y, hd[x]); hd[x] = ecnt;}1819class trie{ // dep = 0,dep > 2020 public: int ch[CN * 30][2], w[CN * 30], val[CN * 30], rt[CN], tot;21 trie() {memset(rt, 0, sizeof(rt)); tot = 0;}22 #define lc ch[u][0]23 #define rc ch[u][1]24 int make() {int u = ++tot; lc = rc = w[u] = val[u] = 0; return tot;}25 void maintain(int u){26 w[u] = val[u] = 0;27 if(lc) w[u] += w[lc], val[u] ^= val[lc] << 1;28 if(rc) w[u] += w[rc], val[u] ^= (val[rc] << 1) | w[rc];29 w[u] &= 1;30 }31 void ins(int &u,int x,int dep){32 if(!u) u = make();33 if(dep > 20) return (void)(w[u] ^= 1);34 ins(ch[u][x & 1], x >> 1, dep + 1);35 maintain(u);36 }37 void addall(int u) {if(rc) addall(rc); swap(lc, rc); maintain(u);}38 int merge(int u,int k){39 if(!k) return u; if(!u) return k;40 w[u] = (w[u] + w[k]) & 1; val[u] ^= val[k];41 lc = merge(lc, ch[k][0]); rc = merge(rc, ch[k][1]);42 return u;43 }44}D;4546int n,v[CN],va[CN];4748void dfs(int u){49 if(!hd[u]){50 va[u] = v[u];51 D.ins(D.rt[u], v[u], 0);52 return;53 }5455 int k = hd[u], s1;56 for(; k; k = E[k].nxt) dfs(E[k].to);57 58 k = hd[u], s1 = E[k].to, k = E[k].nxt, D.rt[u] = D.rt[s1];59 for(; k; k = E[k].nxt){60 int v = E[k].to;61 D.merge(D.rt[u], D.rt[v]);62 }63 D.addall(D.rt[u]), D.ins(D.rt[u], v[u], 0);64 va[u] = D.val[ D.rt[u] ];65}6667int main()68{69 n = read();70 for(int i = 1;i <= n;i++) v[i] = read();71 for(int i = 2;i <= n;i++) add(read(), i);7273 dfs(1);7475 long long ans = 0;76 for(int i = 1;i <= n;i++) ans += 1ll * va[i];7778 printf(“%lld”, ans); 79}cpp
数论
线性筛
高斯消元:OI模板梳理 4.3
乘法逆元
欧几里得系列:欧几里得与扩展欧几里得定理
中国剩余定理系列:模线性方程组与中国剩余定理
矩阵系列:矩阵基础
概论系列:概率与期望
组合学系列:组合数学基础
数据结构
单调栈:音乐会的等待
单调队列,对DP的优化-「题解」Watching Fireworks is Fun
堆:OI模板梳理 1.3,或pq一行完成
并查集:OI模板梳理 1.4
树状数组
线段树,线段覆盖-「题解」Atlantis
数列差分
DP
背包,变式-「题解」硬币购物
树形DP,变式-「题解」重建道路
状压DP
优化:单调队列优化-「题解」Watching Fireworks is Fun,矩阵乘法优化-「题解」摆花
其他DP内容,请参见标签:DP
其它
字符串:KMP-KMP学习笔记
关于本博客的内容,顺便还有之前的Icarus魔改教程,教你一步步走向深渊。
顺便一说,bn 的 luogu 还没有掉蓝(珂怕)。
以上
祝各位新春快乐。
qwq