版本比较
模板
正文
增加 15 行删除 15 行
7 行未改动891011121314151625 行未改动424344454647484950514 行未改动565758596061626364334 行未改动全部展开399400401402403404405406407157 行未改动全部展开565566567568569570571572573129 行未改动全部展开703704705706707708709710711712713714715333 行未改动全部展开104910501051105210531054105510561057486 行未改动全部展开15441545154615471548154915501551155215531554673 行未改动全部展开22282229223022312232223322342235223692 行未改动23292330233123322333233423352336233722 行未改动7 行未改动}}}```### Dijkstra```struct edge {int v, w;};25 行未改动}```### dfs(图上)```vector<vector<int>> adj;vector<bool> vis;void dfs(int s) {stack<int> st;st.push(s);4 行未改动st.pop();for (int v : adj[u]) {if (!vis[v]) {vis[v] = true;st.push(v);}}}334 行未改动全部展开}}```### Kruskal```bool cmp(Edge a,Edge b){return a.w<b.w;}157 行未改动全部展开}}```### Dinic```struct MF {struct edge {int v, nxt, cap, flow;129 行未改动全部展开### DSU```int p[300001];int Find(int x){return p[x]=(x==p[x]?x:Find(p[x]));}bool Judge(int x,int y){return Find(x)==Find(y);}void Merge(int x,int y){p[Find(x)]=Find(y);}```333 行未改动全部展开int mid=l+r>>1;build(p<<1,l,mid);build(p<<1|1,mid+1,r);push_up(p);}void maketag(int p,int pl,int pr,int w){tree[p].v+=(pr-pl+1)*w;tree[p].tag+=w;}486 行未改动全部展开### 替罪羊树```constexpr double ALPHA = 0.7;int id, rt, lc[N], rc[N], tot[N], tot_active;int tmp[N], n_tmp;int val[N], cnt[N], sz[N];void push_up(int x) {tot[x] = 1 + tot[lc[x]] + tot[rc[x]];sz[x] = cnt[x] + sz[lc[x]] + sz[rc[x]];}673 行未改动全部展开}};```### KMP```vector<int> find_occurrences(string text, string pattern) {string cur = pattern + '#' + text;int sz1 = text.size(), sz2 = pattern.size();92 行未改动last = cur;}```### Manacher```vector<int> d1(n);for (int i = 0, l = 0, r = -1; i < n; i++) {int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);22 行未改动7 行未改动891011121314151625 行未改动424344454647484950514 行未改动565758596061626364334 行未改动全部展开399400401402403404405406407157 行未改动全部展开565566567568569570571572573129 行未改动全部展开703704705706707708709710711712713714715333 行未改动全部展开104910501051105210531054105510561057486 行未改动全部展开15441545154615471548154915501551155215531554673 行未改动全部展开22282229223022312232223322342235223692 行未改动23292330233123322333233423352336233722 行未改动7 行未改动}}}```### Dijkstra```struct edge {int v, w;};25 行未改动}```### dfs(图上)```vector<vector<int>> adj;vector<bool> vis;void dfs(int s) {stack<int> st;st.push(s);4 行未改动st.pop();for (int v : adj[u]) {if (!vis[v]) {vis[v] = true;st.push(v);}}}334 行未改动全部展开}}```### Kruskal```bool cmp(Edge a,Edge b){return a.w<b.w;}157 行未改动全部展开}}```### Dinic```struct MF {struct edge {int v, nxt, cap, flow;129 行未改动全部展开### DSU```int p[300001];int Find(int x){return p[x]=(x==p[x]?x:Find(p[x]));}bool Judge(int x,int y){return Find(x)==Find(y);}void Merge(int x,int y){p[Find(x)]=Find(y);}```333 行未改动全部展开int mid=l+r>>1;build(p<<1,l,mid);build(p<<1|1,mid+1,r);push_up(p);}void maketag(int p,int pl,int pr,int w){tree[p].v+=(pr-pl+1)*w;tree[p].tag+=w;}486 行未改动全部展开### 替罪羊树```constexpr double ALPHA = 0.7;int id, rt, lc[N], rc[N], tot[N], tot_active;int tmp[N], n_tmp;int val[N], cnt[N], sz[N];void push_up(int x) {tot[x] = 1 + tot[lc[x]] + tot[rc[x]];sz[x] = cnt[x] + sz[lc[x]] + sz[rc[x]];}673 行未改动全部展开}};```### KMP```vector<int> find_occurrences(string text, string pattern) {string cur = pattern + '#' + text;int sz1 = text.size(), sz2 = pattern.size();92 行未改动last = cur;}```### Manacher```vector<int> d1(n);for (int i = 0, l = 0, r = -1; i < n; i++) {int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);22 行未改动