TAT,我的LCT转双旋了
2015-06-06 11:11
302 查看
这里是rotate和splay函数
View Code
void rotate(int x) { int y=pre[x],z=pre[y],d=ch[y][0]==x; ch[y][d^1]=ch[x][d];pre[ch[x][d]]=y; ch[z][ch[z][1]==y]=x;pre[x]=z; ch[x][d]=y;pre[y]=x;maintain(y); } int q[maxn],top; void splay(int x) { for(int i=x;i;i=pre[i]) q[++top]=i; if(q[top]!=x) fa[x]=fa[q[top]],fa[q[top]]=0; while(top) pushdown(q[top--]); while(pre[x]) { int y=pre[x],z=pre[y]; if(pre[y]) if(ch[y][0]==x^ch[z][0]==y) rotate(x);else rotate(y); rotate(x); } maintain(x); }
View Code
相关文章推荐
- Leetcode[12-13] Roman to Integer & Integer to Roman(Java)
- arduino小车马达原理
- hdu 1849 (尼姆博弈)
- Shell awk 求标准差
- 【转】 linux内核移植和网卡驱动(二)
- 理解String不可变
- CSS Padding(填充)
- pom.xml第一行报错
- UIImage基础语法
- 软件概要设计与详细设计的区别
- 将CorelDRAW文件转成PSD分层文件详解
- 【转】 linux内核移植和驱动添加(三)
- JavaScript中String.match()方法的使用详解
- DEV C++使用说明
- setRestoreOriginalFrame
- 《机器学习实战》-朴素贝叶斯笔记
- LightOJ1011---Marriage Ceremonies (状压dp)
- surface pro 3系统运行中关闭fn功能键
- 程序员修炼之路
- ZigBee之无线射频程序解析