跳到正文

算法·理论

总结

yangzichen1203约 41 分钟
原文
文章信息与版本

文章信息

发布
2025年12月3日
收录
2026年1月6日
更新
2026年11月15日
篇幅
约 41 分钟
获赞
1

版本

  1. v2当前
  2. v1
全家桶
Deque:O(n)−O(1)O(n)-O(1)
C++
class Deque{
	private:
		vector<int> L,R;
		int sz;
		void balanceL(){
			int sz=R.size();
			dFor(i,sz/2,0){
				L.push_back(R[i]);
			}
			dFor(i,sz-1,sz/2+1){
				R[i-sz/2-1]=R[i];
			}
			For(i,0,sz/2){
				R.pop_back();
			}
		}
		void balanceR(){
			int sz=L.size();
			dFor(i,sz/2,0){
				R.push_back(L[i]);
			}
			dFor(i,sz-1,sz/2+1){
				L[i-sz/2-1]=L[i];
			}
			For(i,0,sz/2){
				L.pop_back();
			}
		}
	public:
		void push_back(int x){
			R.push_back(x);
			sz++;
		}
		void push_front(int x){
			L.push_back(x);
			sz++;
		}
		void pop_back(){
			if(sz==0) return ;
			if(R.empty()){
				balanceR();
			}
			R.pop_back();
			sz--;
		}
		void pop_front(){
			if(sz==0) return ;
			if(L.empty()){
				balanceL();
			}
			L.pop_back();
			sz--;
		}
		int size(){
			return sz;
		}
		int front(){
			if(sz==0) return -1;
			if(L.empty()){
				balanceL();
			}
			return L.back();
		}
		int back(){
			if(sz==0) return -1;
			if(R.empty()){
				balanceR();
			}
			return R.back();
		}
};
线段树 min⁡,max⁡\min,\max:O(n)−O(log⁡n)O(n)-O(\log n)
C++
class SGT{
	private:
		int a[MAXN];
		struct Node{
			int l,r,min,max;
		}tr[MAXN*4];
		void update(int c){
			tr[c].min=min(tr[c*2].min,tr[c*2+1].min);
			tr[c].max=max(tr[c*2].max,tr[c*2+1].max);
		}
		void build(int c,int l,int r){
			tr[c].l=l;tr[c].r=r;
			if(l==r){
				tr[c].min=tr[c].max=a[l];
				return ;
			}
			int mid=(l+r)/2;
			build(c*2,l,mid);
			build(c*2+1,mid+1,r);
			update(c);
		}
		int querymin(int c,int l,int r){
			if(tr[c].l==l&&tr[c].r==r){
				return tr[c].min;
			}
			int mid=(tr[c].l+tr[c].r)/2;
			if(r<=mid) return querymin(c*2,l,r);
			else if(l>mid) return querymin(c*2+1,l,r);
			else return min(querymin(c*2,l,mid),querymin(c*2+1,mid+1,r));
		}
		int querymax(int c,int l,int r){
			if(tr[c].l==l&&tr[c].r==r){
				return tr[c].max;
			}
			int mid=(tr[c].l+tr[c].r)/2;
			if(r<=mid) return querymax(c*2,l,r);
			else if(l>mid) return querymax(c*2+1,l,r);
			else return max(querymax(c*2,l,mid),querymax(c*2+1,mid+1,r));
		}
	public:
		void build(int n,int *b){
			For(i,1,n){
				a[i]=b[i];
			}
			build(1,1,n);
		}
		int querymin(int l,int r){
			return querymin(1,l,r);
		}
		int querymax(int l,int r){
			return querymax(1,l,r);
		}
};
线段树 add,cov:O(n)−O(log⁡n)O(n)-O(\log n)
C++
namespace SGT{
    struct Node{
        int l,r;
        long long sum,add;
        bool cov;
    }tr[MAXN*4];
    void build(int c,int L,int R){
        tr[c].l=L;tr[c].r=R;
        tr[c].sum=tr[c].add=tr[c].cov=0;
        if(L==R) return ;
        int mid=(L+R)>>1;
        build(c*2,L,mid);
        build(c*2+1,mid+1,R);
    }
    void update(int c){
        tr[c].sum=tr[c*2].sum+tr[c*2+1].sum;
    }
    void Add(int c,long long k){
        tr[c].sum+=k*(tr[c].r-tr[c].l+1);
        tr[c].add+=k;
    }
    void Cov(int c){
        tr[c].sum=0;
        tr[c].add=0;
        tr[c].cov=1;
    }
    void down(int c){
        if(tr[c].cov){
            Cov(c*2);
            Cov(c*2+1);
            tr[c].cov=0;
        }
        if(tr[c].add!=0){
            Add(c*2,tr[c].add);
            Add(c*2+1,tr[c].add);
            tr[c].add=0;
        }
    }
    void add(int c,int l,int r,int k){
        if(l==tr[c].l&&r==tr[c].r){
            Add(c,k);
            return ;
        }
        down(c);
        int mid=(tr[c].l+tr[c].r)>>1;
        if(r<=mid) add(c*2,l,r,k);
        else if(l>mid) add(c*2+1,l,r,k);
        else add(c*2,l,mid,k),add(c*2+1,mid+1,r,k);
        update(c);
    }
    void cover(int c,int l,int r){
        if(l==tr[c].l&&r==tr[c].r){
            Cov(c);
            return ;
        }
        down(c);
        int mid=(tr[c].l+tr[c].r)>>1;
        if(r<=mid) cover(c*2,l,r);
        else if(l>mid) cover(c*2+1,l,r);
        else cover(c*2,l,mid),cover(c*2+1,mid+1,r);
        update(c);
    }
    long long query(int c,int l,int r){
        if(l==tr[c].l&&r==tr[c].r){
            return tr[c].sum;
        }
        down(c);
        int mid=(tr[c].l+tr[c].r)>>1;
        if(r<=mid) return query(c*2,l,r);
        else if(l>mid) return query(c*2+1,l,r);
        else return query(c*2,l,mid)+query(c*2+1,mid+1,r);
    }
}
ST 表:O(nlog⁡n)−O(1)O(n\log n)-O(1)
C++
class ST{
	private:
		int lg[MAXN],f[MAXN][MAXK];
	public:
		void build(int n,int *a){
			lg[1]=0;
			For(i,2,n){
				lg[i]=lg[i>>1]+1;
			}
			For(i,1,n){
				f[i][0]=a[i];
			}
			For(j,1,MAXK-1){
				For(i,1,n-(1<<j)+1){
					f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]);
				}
			}
		}
		int query(int l,int r){
			int x=lg[r-l+1];
			return min(f[l][x],f[r-(1<<x)+1][x]);
		}
};
Four Russian(B=nB=\sqrt n):期望 O(n)−O(1)O(n)-O(1)
C++
class FR2{
	private:
		int a[MAXN];
		int sz,bs,L[MAXM],R[MAXM],id[MAXN];
		int pre[MAXN],suf[MAXN];
		int Min[MAXM],ans[MAXM][MAXM];
	public:
		void build(int n,int *b){
			For(i,1,n){
				a[i]=b[i];
			}
			For(i,1,bs){
				Min[i]=2147483647;
				For(j,L[i],R[i]){
					Min[i]=min(Min[i],a[j]);
					id[j]=i;
				}
				pre[L[i]]=a[L[i]];
				For(j,L[i]+1,R[i]){
					pre[j]=min(pre[j-1],a[j]);
				}
				suf[R[i]]=a[R[i]];
				dFor(j,R[i]-1,L[i]){
					suf[j]=min(suf[j+1],a[j]);
				}
			}
			For(i,1,bs){
				For(j,i,bs){
					ans[i][j]=min(ans[i][j-1],Min[j]);
				}
			}
		}
		int query(int l,int r){
			if(id[l]==id[r]){
				int Min=0;
				For(j,l,r){
					Min=min(Min,a[j]);
				}
				return Min;
			}
			int Min=ans[id[l]+1][id[r]-1];
			if(suf[l]<Min){
				Min=suf[l];
			}
			if(pre[r]<Min){
				Min=pre[r];
			}
			return Min;
		}
};
树状数组(单点修改,区间和):O(nlog⁡n)/O(n)−O(log⁡n)−O(log⁡n)O(n\log n)/O(n)-O(\log n)-O(\log n)
C++
class Bit1{
	private:
		int n,tr[MAXN];
	public:
		void build(int m,int *a){
			n=m;
			For(i,1,n){
				tr[i]+=a[i];
				int j=i+(i&-i);
				if(j<=n) tr[j]+=tr[i];
			}
		}
		void add(int x,int k){
			while(x<=n){
				tr[x]+=k;
				x+=x&-x;
			}
		}
		int query(int x){
			int ans=0;
			while(x){
				ans+=tr[x];
				x-=x&-x;
			}
			return ans;
		}
		int query(int l,int r){
			return query(r)-query(l-1);
		}
};
分块(单点修改,区间和):O(n)−O(1)−O(n)O(n)-O(1)-O(\sqrt n)
C++
class Block1{
	private:
		int bs,sz,L[MAXM],R[MAXM],id[MAXN];
		int a[MAXN],b[MAXM];
	public:
		void build(int n,int *t){
            For(i,1,n){
                a[i]=t[i];
            }
			sz=sqrt(n);bs=n/sz;
			For(i,1,bs-1){
				L[i]=(i-1)*sz+1;
				R[i]=i*sz;
			}
			L[bs]=(bs-1)*sz+1;R[bs]=n;
			For(i,1,bs){
				For(j,L[i],R[i]){
					id[j]=i;
					b[i]+=a[j];
				}
			}
		}
		void add(int x,int k){
			a[x]+=k;
			b[id[x]]+=k;
		}
		int query(int l,int r){
            int ans=0;
            if(id[l]==id[r]){
                For(i,l,r){
                    ans+=a[i];
                }
                return ans;
            }
			For(i,l,R[id[l]]){
				ans+=a[i];
			}
			For(i,id[l]+1,id[r]-1){
				ans+=b[i];
			}
			For(i,L[id[r]],r){
				ans+=a[i];
			}
			return ans;
		}
};
分块(单点修改,区间和):O(n)−O(n)−O(1)O(n)-O(\sqrt n)-O(1)
C++
class Block2{
	private:
		int bs,sz,L[MAXM],R[MAXM],id[MAXN];
		int a[MAXN],b[MAXM];
		int query(int x){
			return b[id[x]-1]+a[x];
		}
	public:
		void build(int n,int *t){
			For(i,1,n){
				a[i]=t[i];
			}
			sz=sqrt(n);bs=n/sz;
			For(i,1,bs-1){
				L[i]=(i-1)*sz+1;
				R[i]=i*sz;
			}
			L[bs]=(bs-1)*sz+1;R[bs]=n;
			For(i,1,bs){
				b[i]=b[i-1];
				For(j,L[i],R[i]){
					id[j]=i;
					b[i]+=a[j];
				}
				For(j,L[i]+1,R[i]){
					a[j]+=a[j-1];
				}
			}
		}
		void add(int x,int k){
			For(i,x,R[id[x]]){
				a[i]+=k;
			}
			For(i,id[x],bs){
				b[i]+=k;
			}
		}
		int query(int l,int r){
			return query(r)-query(l-1);
		}
};
树状数组(区间加,单点查询):O(nlog⁡n)/O(n)−O(log⁡n)−O(log⁡n)O(n\log n)/O(n)-O(\log n)-O(\log n)
C++
class Bit2{
	private:
		Bit1 t;
	public:
		void build(int n,int *a){
            dFor(i,n,1){
                a[i]-=a[i-1];
            }
			t.build(n,a);
		}
		void add(int l,int r,int k){
			t.add(l,k);
			t.add(r+1,-k);
		}
		int query(int x){
			return t.query(x);
		}
};
分块(区间加,单点查询):O(n)−O(1)−O(n)O(n)-O(1)-O(\sqrt n)
C++
class Block3{
	private:
		Block1 b;
	public:
		void build(int n,int *a){
            dFor(i,n,1){
                a[i]-=a[i-1];
            }
			b.build(n,a);
		}
		void add(int l,int r,int k){
			b.add(l,k);
			b.add(r+1,-k);
		}
		int query(int x){
			return b.query(1,x);
		}
};
分块(区间加,单点查询):O(n)−O(n)−O(1)O(n)-O(\sqrt n)-O(1)
C++
class Block4{
	private:
		int bs,sz,L[MAXM],R[MAXM],id[MAXN];
		int a[MAXN],lzy[MAXM];
		void down(int c){
			if(lzy[c]!=0){
				For(i,L[c],R[c]){
					a[i]+=lzy[c];
				}
				lzy[c]=0;
			}
		}
	public:
		void build(int n,int *t){
			For(i,1,n){
				a[i]=t[i];
			}
			sz=sqrt(n);bs=n/sz;
			For(i,1,bs-1){
				L[i]=(i-1)*sz+1;
				R[i]=i*sz;
			}
			L[bs]=(bs-1)*sz+1;R[bs]=n;
			For(i,1,bs){
				For(j,L[i],R[i]){
					id[j]=i;
				}
			}
		}
		void add(int l,int r,int k){
			if(id[l]==id[r]){
				down(id[l]);
				For(i,l,r){
					a[i]+=k;
				}
				return ;
			}
			down(id[l]);
			For(i,l,R[id[l]]){
				a[i]+=k;
			}
			down(id[r]);
			For(i,L[id[r]],r){
				a[i]+=k;
			}
			For(i,id[l]+1,id[r]-1){
				lzy[i]+=k;
			}
		}
		int query(int x){
			return a[x]+lzy[id[x]];
		}
};
树状数组(区间加,区间和):O(nlog⁡n)/O(n)−O(log⁡n)−O(log⁡n)O(n\log n)/O(n)-O(\log n)-O(\log n)
C++
class Bit3{
	private:
		Bit1 t1,t2;
		void add(int x,int k){
			t1.add(x,k);
			t2.add(x,x*k);
		}
	public:
		void build(int n,int *a){
			dFor(i,n,1){
				a[i]-=a[i-1];
			}
			t1.build(n,a);
			For(i,1,n){
				a[i]*=i;
			}
			t2.build(n,a);
		}
		void add(int l,int r,int k){
			add(l,k);
			add(r+1,-k);
		}
		int query(int l,int r){
			return (t1.query(r)*(r+1)-t2.query(r))-(t1.query(l-1)*l-t2.query(l-1));
		}
};
二维树状数组(单点修改,区间查询):O(nlog⁡2n)−O(log⁡2n)−O(log⁡2n)O(n\log^2n)-O(\log^2n)-O(\log^2n)
C++
class BitBit{
	private:
		__gnu_pbds::gp_hash_table<int,int> tr[MAXN];
	public:
		void add(int x,int y,int k){
			for(int i=x;i<=V1;i+=i&-i){
				for(int j=y;j<=V2;j+=j&-j){
					tr[i][j]+=k;
				}
			}
		}
		void erase(int x,int y){
			for(int i=x;i<=V1;i+=i&-i){
				for(int j=y;j<=V2;j+=j&-j){
					tr[i].erase(j);
				}
			}
		}
		int query(int x,int y){
			int ans=0;
			for(int i=x;i;i-=i&-i){
				if(tr[i].empty()) continue;
				for(int j=y;j;j-=j&-j){
					if(tr[i].find(j)==tr[i].end()) continue;
					ans+=tr[i][j];
				}
			}
			return ans;
		}
};
树状数组套线段树(单点修改,区间查询):O(nlog⁡2n)−O(log⁡2n)−O(log⁡2n)O(n\log^2n)-O(\log^2n)-O(\log^2n)
C++
class BitSGT{
	private:
		int cnt=0;
		struct Node{
			int ls,rs,max;
		}tr[MAXN*256];
		int rt[MAXN];
		int newnode(){
			cnt++;
			tr[cnt].ls=tr[cnt].rs=tr[cnt].max=0;
			return cnt;
		}
		void modify(int &c,int L,int R,int x,int k){
			if(!c) c=newnode();
			tr[c].max=max(tr[c].max,k);
			if(L==R) return ;
			int mid=(L+R)/2;
			if(x<=mid) modify(tr[c].ls,L,mid,x,k);
			else modify(tr[c].rs,mid+1,R,x,k);
		}
		int query(int c,int L,int R,int x){
			if(!c) return 0;
			if(L==R) return tr[c].max;
			int mid=(L+R)/2;
			if(x<=mid) return query(tr[c].ls,L,mid,x);
			else return max(tr[tr[c].ls].max,query(tr[c].rs,mid+1,R,x));
		}
	public:
		void add(int x,int y,int k){
			while(x<=V1){
				modify(rt[x],1,V2,y,k);
				x+=x&-x;
			}
		}
		void clear(int x){
			while(x<=V1){
				rt[x]=0;
				x+=x&-x;
			}
			cnt=0;
		}
		int query(int x,int y){
			int ans=0;
			while(x){
				ans=max(ans,query(rt[x],1,V2,y));
				x-=x&-x;
			}
			return ans;
		}
};
LCT:O(n)−O(log⁡n)O(n)-O(\log n)
C++
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define dFor(i,j,k) for(int i=j;i>=k;i--)
using namespace std;
#define MAXN 10005
#define ls son[0]
#define rs son[1]
#define endl '\n'
int n,q;
struct Node{
	int son[2],fa;
	bool rev;
}tr[MAXN];
bool dir(int x){
	return tr[tr[x].fa].rs==x;
}
bool isroot(int x){
	return tr[tr[x].fa].son[dir(x)]!=x;
}
void rev(int x){
	if(!x) return ;
	swap(tr[x].ls,tr[x].rs);
	tr[x].rev^=1;
}
void pushdown(int x){
	if(tr[x].rev){
		rev(tr[x].ls);
		rev(tr[x].rs);
		tr[x].rev=0;
	}
}
void rotate(int x){
	int y=tr[x].fa,z=tr[y].fa;
	bool r=dir(x);
	if(!isroot(y)) tr[z].son[dir(y)]=x;
	tr[y].son[r]=tr[x].son[!r];
	tr[x].son[!r]=y;
	if(tr[y].son[r]) tr[tr[y].son[r]].fa=y;
	tr[y].fa=x;
	tr[x].fa=z;
}
int st[MAXN],top=0;
void splay(int x){
	top=0;
	int u=x;
	st[++top]=u;
	while(!isroot(u)){
		u=tr[u].fa;
		st[++top]=u;
	}
	dFor(i,top,1){
		pushdown(st[i]);
	}
	while(!isroot(x)){
		int y=tr[x].fa;
		if(!isroot(y)){
			rotate(dir(x)==dir(y)?y:x);
		}
		rotate(x);
	}
}
void access(int x){
	int y=0;
	while(x){
		splay(x);
		tr[x].son[1]=y;
		y=x;
		x=tr[x].fa;
	}
}
void makeroot(int x){
	access(x);
	splay(x);
	rev(x);
}
void link(int x,int y){
	makeroot(x);
	tr[x].fa=y;
}
int findroot(int x){
	access(x);
	splay(x);
	pushdown(x);
	while(tr[x].ls){
		x=tr[x].ls;
		pushdown(x);
	}
	splay(x);
	return x;
}
void cut(int x,int y){
	makeroot(x);
	findroot(y);
	tr[x].rs=tr[y].fa=0;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>q;
	while(q--){
		string op;
		int x,y;
		cin>>op>>x>>y;
		if(op=="Connect"){
			link(x,y);
		}else if(op=="Destroy"){
			cut(x,y);
		}else{
			if(findroot(x)==findroot(y)) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
	return 0;
}
Dinic:O(n2m)O(n^2m)
C++
class Dinic{
	private:
		struct Edge{
			int to,rev;
			long long cap;
		};
		int n;
		vector<vector<Edge>> g;
		vector<int> dis,it;
		bool bfs(int s,int t){
			fill(dis.begin(),dis.end(),0);
			queue<int> q;
			dis[s]=1;
			q.push(s);
			while(!q.empty()){
				int u=q.front();
				q.pop();
				for(auto &e:g[u]){
					if(!dis[e.to]&&e.cap>0){
						dis[e.to]=dis[u]+1;
						q.push(e.to);
					}
				}
			}
			return dis[t]!=0;
		}
		long long dfs(int u,int t,long long f){
			if(u==t) return f;
			for(int &i=it[u];i<(int)g[u].size();i++){
				Edge &e=g[u][i];
				if(e.cap<=0) continue;
				if(dis[e.to]!=dis[u]+1) continue;
				long long push=dfs(e.to,t,min(f,e.cap));
				if(push>0){
					e.cap-=push;
					g[e.to][e.rev].cap+=push;
					return push;
				}
			}
			return 0;
		}
	public:
		Dinic(int n=0):n(n){
			g.assign(n+1,{});
			dis.assign(n+1,{});
			it.assign(n+1,{});
		}
		void add(int u,int v,long long w){
			int szu=g[u].size(),szv=g[v].size();
			g[u].push_back({v,szv,w});
			g[v].push_back({u,szu,0});
		}
		long long maxflow(int s,int t){
			const long long inf=(1ll<<60);
			long long flow=0;
			while(bfs(s,t)){
				fill(it.begin(),it.end(),0);
				while(1){
					long long push=dfs(s,t,inf);
					if(!push) break;
					flow+=push;
				}
			}
			return flow;
		}
};
Math
C++
inline int md(int x){
	if(x>=Mod) return x-Mod;
	else return x;
}
int f[MAXN],g[MAXN];
int Pow(int x,int y){
	int ans=1;
	while(y){
		if(y&1){
			ans=1ll*ans*x%Mod;
		}
		x=1ll*x*x%Mod;
		y>>=1;
	}
	return ans;
}
void init(){
	f[0]=1;
	For(i,1,1000000){
		f[i]=1ll*f[i-1]*i%Mod;
	}
	g[1000000]=Pow(f[1000000],Mod-2);
	dFor(i,1000000-1,0){
		g[i]=1ll*g[i+1]*(i+1)%Mod;
	}
}
inline int C(int n,int m){
	if(m>n) return 0;
	else return 1ll*f[n]*g[m]%Mod*g[n-m]%Mod;
}
FastIO
C++
struct IO {
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
  char buf[MAXSIZE], *p1, *p2;
  char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
  IO() : p1(buf), p2(buf), pp(pbuf) {}

  ~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }
#endif
  char gc() {
#if DEBUG  // ??,?????
    return getchar();
#endif
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    return p1 == p2 ? ' ' : *p1++;
  }

  void read(int &x) {
    bool neg = false;
    x = 0;
    char ch = gc();
    for (; !isdigit(ch); ch = gc())
      if (ch == '-') neg = true;
    if (neg)
      for (; isdigit(ch); ch = gc()) x = x * 10 + ('0' - ch);
    else
      for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - '0');
  }

  void read(char *s) {
    char ch = gc();
    for (; isspace(ch); ch = gc());
    for (; !isspace(ch); ch = gc()) *s++ = ch;
    *s = 0;
  }

  void read(char &c) { for (c = gc(); isspace(c); c = gc()); }

  void push(const char &c) {
#if DEBUG  // ??,?????
    putchar(c);
#else
    if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
    *pp++ = c;
#endif
  }

  void write(long long x) {
    bool neg = false;
    if (x < 0) {
      neg = true;
      push('-');
    }
    static int sta[40];
    int top = 0;
    do {
      sta[top++] = x % 10;
      x /= 10;
    } while (x);
    if (neg)
      while (top) push('0' - sta[--top]);
    else
      while (top) push('0' + sta[--top]);
  }

  void write(long long x, char lastChar) { write(x), push(lastChar); }
} io;
错题本
总结贴
1.其他

https://www.luogu.com.cn/discuss/1199853 (点分治找了树的中心而不是重心)

https://www.luogu.com.cn/discuss/1196388 (李超线段树的构造函数写错)

https://www.luogu.com.cn/discuss/1222937 (01 bfs 写错)

https://www.luogu.com.cn/discuss/1227360 (线段树分治回滚顺序反了)

https://www.luogu.com.cn/discuss/1227364 (题目读错+并查集写错)

https://www.luogu.com.cn/discuss/1227812 (线段树没判区间是否存在导致 TLE)

https://www.luogu.com.cn/discuss/1230198 (犯唐)

https://www.luogu.com.cn/discuss/1233180 (退化成暴力没发现)

https://www.luogu.com.cn/discuss/1233487 (FWT 不能定长变换)

https://www.luogu.com.cn/discuss/1233730 (无序对转有序对)

https://www.luogu.com.cn/discuss/1233893 (有关卡空间)

https://www.luogu.com.cn/discuss/1281663 (爆精度)

https://www.luogu.com.cn/discuss/1278162 (00 号节点未初始化)

https://www.luogu.com.cn/discuss/1259621 (segment tree beats)

https://www.luogu.com.cn/discuss/1253997 (犯唐)

https://www.luogu.com.cn/discuss/1253194 (全局变量被覆盖)

https://www.luogu.com.cn/discuss/1241561 (并查集)

https://www.luogu.com.cn/discuss/1241092 (忘记特判)

https://www.luogu.com.cn/discuss/1236301 (犯唐)

2.数组开小了

https://www.luogu.com.cn/discuss/1213198 (总结帖)

https://www.luogu.com.cn/discuss/1216822 (dfn 序 2 倍空间)

https://www.luogu.com.cn/discuss/1214457 (值域分块加 eps 空间)

https://www.luogu.com.cn/discuss/1211041 (主席树 256 倍空间)

https://www.luogu.com.cn/discuss/1210711 (数组恰好越界到其他数组)

https://www.luogu.com.cn/discuss/1209765 (动态开点线段树 64 倍空间)

https://www.luogu.com.cn/discuss/1209764 (线段树 4 倍空间)

https://www.luogu.com.cn/discuss/1195485 (值域是 105+110^5+1)

https://www.luogu.com.cn/discuss/1170012 (数组开小了)

https://www.luogu.com.cn/discuss/1225361 (阈值错误导致爆数组越界)

https://www.luogu.com.cn/discuss/1256701 (懒标记忘记处理)

3.爆 int
4.FHQ-Treap
5.位运算
5.多测不清空
6.while 写成 if
7.动态树

https://www.luogu.com.cn/discuss/1220390 (LCT isroot 写错)

https://www.luogu.com.cn/discuss/1221868 (splay 忘记全部 pushdown)

https://www.luogu.com.cn/discuss/1221879 (LCT cut 写错)

https://www.luogu.com.cn/discuss/1222205 (静态 Top Tree DAC 写错)

https://www.luogu.com.cn/discuss/1233183 (Rake/Compress 写错+卡卡就过了)

https://www.luogu.com.cn/discuss/1233475 (Rake/Compress 写错)

8.细节问题
9.树剖!!!!!!!!!!
原文