版本比较
『代码笔记』各种模板
正文
增加 16 行删除 16 行
73 行未改动7475767778787980818292 行未改动17517617717817917918018118218312 行未改动19619719819920020020120220320422 行未改动22722822923023123123223323423530 行未改动266267268269270270271272273274275275276277278279327 行未改动全部展开607608609610611611612613614615615616617618619620621620621622623624625626627628627628629630630631632633634635636637638639640640641642643644644645646647647648649650651356 行未改动全部展开73 行未改动 else if(op == 2) updata2(1,aa,bb,d); else cout << ask(1,aa,bb) % m << endl; } return 0;} }```
## [P3388 割点(割顶)](https://www.luogu.com.cn/problem/P3388) - Tarjan```cpp92 行未改动#define min(u,v) (u<v?u:v)#define add(u,v) (++cnt,to[cnt] = v,next1[cnt] = head[u],head[u] = cnt)int n,m,to[5145140],next1[5145140],head[5145140],cnt,xx,yy,num,dfn[5145140],low[5145140];int sta[5145140],top,bingchaji[5145140];int ans;//联通块个数 int ans;//联通块个数bool vis[5145140];int find(int x){ if(bingchaji[x] != x) bingchaji[x] = find(bingchaji[x]); return bingchaji[x];12 行未改动 //p[ans].push_back(x); } } else if(y != father || f) low[x] = min(low[x],dfn[y]); if(y == father) f = 1; if(y == father) f = 1; } //if(father == -1 && f2 == 0) p[++ans].push_back(x);}signed main(){22 行未改动```cpp#include<bits/stdc++.h>using namespace std;int n,m,w[114514],u[114514],v[114514];int head[114514],g[114514],cnt,next1[114514],r,sum; int head[114514],g[114514],cnt,next1[114514],r,sum;int dfn[114514],low[114514];int stack1[114514],top;int instack[114514];int bingchaji[114514],quan[114514];30 行未改动 low[x] = min(low[x],dfn[to]); } else if(dfn[to] == 0){ tarjan(to); low[x] = min(low[x],low[to]); low[x] = min(low[x],low[to]); } } if(dfn[x] == low[x]){ while(top > 0){ int p = stack1[top--]; int p = stack1[top--]; instack[p] = 0; if(x != p){ quan[x] += quan[p]; bingchaji[p] = x;327 行未改动全部展开int n,op,x1,root = 0,cnt;struct ppp{ int ls,rs,key,pri,size1;}tree[1000006];inline void newnote(int x){//产生新节点 inline void newnote(int x){//产生新节点 ++cnt; tree[cnt].size1 = 1,tree[cnt].key = x; tree[cnt].ls = tree[cnt].rs = 0; tree[cnt].pri = rand();//随机优先级 tree[cnt].pri = rand();//随机优先级}inline void update(int x){ tree[x].size1 = tree[tree[x].ls].size1 + tree[tree[x].rs].size1 + 1;}inline void split(int u,int x,int &l,int &r){//美其名曰分裂,其实就是把一个树拆成大于x和小于等于x的两部分 if(u == 0){//叶子节点 inline void split(int u,int x,int &l,int &r){//美其名曰分裂,其实就是把一个树拆成大于x和小于等于x的两部分 if(u == 0){//叶子节点 l = r = 0; return; } if(tree[u].key <= x) l = u,split(tree[u].rs,x,tree[u].rs,r); else r = u,split(tree[u].ls,x,l,tree[u].ls); update(u);//更新大小 } update(u);//更新大小}inline int merge(int x,int y){ if(x == 0 || y == 0) return x + y;//其实就是返回不为0的那个,如果都为0返回0 if(x == 0 || y == 0) return x + y;//其实就是返回不为0的那个,如果都为0返回0 if(tree[x].pri > tree[y].pri){ tree[x].rs = merge(tree[x].rs,y),update(x); return x; } else{ tree[y].ls = merge(x,tree[y].ls),update(y); return y; }}inline void insert(int x){//插入 inline void insert(int x){//插入 int l,r; split(root,x,l,r);//拆开 newnote(x); root = merge(merge(l,cnt),r);//合并 root = merge(merge(l,cnt),r);//合并}inline void del(int x){ int l,r,d;//A:l B:r C:l D:d int l,r,d;//A:l B:r C:l D:d split(root,x,l,r),split(l,x-1,l,d); d = merge(tree[d].ls,tree[d].rs); root = merge(merge(l,d),r);}356 行未改动全部展开