两个一起学的,就放一块了. 主要是用来存板子. Splay //This is a Splay Tree. #include <cstdio> #include <cstring> using namespace std; const int N=1e5+5,INF=0x3f3f3f3f; int n,root,cntnode; struct node //始终满足左小右大 { int fa,ch[2],val,siz,cnt; //int mark; //区间反转标记 }t[N]
题目链接 splay: #include<bits/stdc++.h> using namespace std; typedef long long ll; ,inf=0x3f3f3f3f; ],val[N],siz[N],rev[N],tot,n,m,a[N],rt; ,ch[u][]=ch[u][]=rev[u]=; return u;} ]]+siz[ch[u][]]+;} ,swap(ch[u][],ch[u][]),rev[ch[u][]]^=,rev[ch[u][]]^=;} vo