1 #include<bits/stdc++.h> 2 #define lc(x) t[x][0] 3 #define rc(x) t[x][1] 4 using namespace std; 5 const int N=100005; 6 const int inf=0x3f3f3f3f; 7 struct LCT{ 8 int t[N][2],s[N],rev[N],fa[N],sx[N],sz[N],tp; 9 void pushup(int x){ 10 sz[x]=sz[lc(x)]+sz[rc(x)]+sx[x]+1; 11 } bool pdrt(int x){ 12 return rc(fa[x])!=x&&lc(fa[x])!=x; 13 } void revers(int x){ 14 rev[x]^=1;swap(lc(x),rc(x)); 15 } void pushdown(int x) return ; 20 } void rotate(int x) void splay(int x) pushup(x);return ; 38 } void access(int x){ 39 for(int i=0;x;x=fa[i=x]) 40 splay(x),sx[x]+=sz[rc(x)], 41 sx[x]-=sz[rc(x)=i],pushup(x); 42 } void mkrt(int x){ 43 access(x);splay(x);revers(x); 44 } void split(int x,int y){ 45 mkrt(x);access(y);splay(y); 46 } void link(int x,int y){ 47 split(x,y);sx[fa[x]=y]+=sz[x]; 48 pushup(y); 49 } int update(int x) 57 else if(np>x) np=x; 58 } if(nl<nr) ls+=sz[l]+sx[x]+1,x=r; 59 else rs+=sz[r]+sx[x]+1,x=l; 60 } splay(np);return np; 61 } 62 }t;int n,m,fa[N]; 63 int get(int x) int main() else if(c[0]=='Q') else printf("%d ",rox); 81 } return 0; 82 }
PLCT检查是什么Luogu P4299 首都 LCT
未经允许不得转载:上海聚慕医疗器械有限公司 » PLCT检查是什么Luogu P4299 首都 LCT












