除夕闲扯

除夕闲扯

此页面中的索引截至 2020.1.24,其中的某些条目可能已经失效。

文化课真好系列。

为了证明 bn 还没入坟,他决定闲的没事瞎bb几句。

所以他对之前的 post 们搞了一个整理,以备后人之用自己欣赏。

图论

最短路

连通性

网络

二分图

欧拉图:欧拉路

x 1#include2#include3#include4#include5using namespace std;6​7const int CN = 6e5+5;8​9int 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}15​16class 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;}18​19class 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;45​46int n,v[CN],va[CN];47​48void dfs(int u){49    if(!hd[u]){50        va[u] = v[u];51        D.ins(D.rt[u], v[u], 0);52        return;53   }54​55    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}66​67int 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);72​73    dfs(1);74​75    long long ans = 0;76    for(int i = 1;i <= n;i++) ans += 1ll * va[i];77​78    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

作者

ce-amtic

发布于

2020-01-24

更新于

2023-04-15

许可协议

CC BY-NC-SA 4.0

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×