随笔分类 -  splay tree

摘要:惭愧。。。 1 #include 2 const int maxn=200010; 3 int lim; 4 struct splaytree 5 { 6 int sz[maxn]; 7 int ch[maxn][2]; 8 int pre[maxn]; 9 int rt,top; 10 inline void up(int x) 11 { 12 sz[x]=cnt[x]+sz[ch[x][0]]+sz[ch[x][1]]; 13 } 14 inline void rotate(int x,int... 阅读全文
posted @ 2013-11-07 20:39 sooflow 阅读(242) 评论(0) 推荐(0)
摘要:splay第一道题,没什么感想。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=1000010; 6 int pre[maxn],ch[maxn][2],key[maxn]; 7 int root,tot; 8 void newnode(int &r,int fa,int k) 9 { 10 r=++tot; 11 pre[r]=fa; 12 key[r]=k; 13 ch[r][1]=ch[r][0]=0; 14 } 15 void initi... 阅读全文
posted @ 2013-11-06 15:21 sooflow 阅读(172) 评论(0) 推荐(0)