splay
文章平均质量分 80
zhhx2001
这个作者很懒,什么都没留下…
展开
-
文艺平衡树(splay旋转操作)
您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 2 3 4 1 #include#include#include#includeusing namespace std;const int maxn=300009;int ch[maxn][2],fa[m原创 2016-06-24 09:41:03 · 322 阅读 · 0 评论 -
bzoj1056(挖个坑wa+tle,平衡树)
代码题。。。虽然还没有过,但是有学了一些经验1、中间就可以直接普通的输入输出了freopen("rank.in","r",stdin);freopen("rank.out","w",stdout); fclose(stdin);fclose(stdout);2、原创 2016-07-26 10:24:14 · 674 阅读 · 0 评论 -
郁闷的出纳员(splay)
bzoj一直 runtimecodevs ac,表示无语。。。,应该是自己写炸了#include#include#include#include#include#includeusing namespace std;const int maxn=3000009;int ch[maxn][2],n,mi,fa[maxn],id=0,w[maxn],size[maxn]原创 2016-06-23 18:03:50 · 489 阅读 · 0 评论 -
splay各操作伪代码
删除PROCEDURE Delete(x) Splay(x, 0) y ← LeftSon[x] WHILE (RightSon[y] != 0) //求x的前驱:左子树里值最大的一个 y ← RightSon[y] END WHILE z ← RightSon[x] WHILE (LeftSon[z] != 0) //求原创 2016-06-23 17:59:11 · 465 阅读 · 0 评论 -
自己的splay模版(bzoj1588)
#include#include#includeusing namespace std;const int maxn=1000005;const int inf=0x3f3f3f3f;int id=0,ch[maxn][2],w[maxn],fa[maxn],root,n;void rotate(int x)///重要的rotate操作{ int y=fa[x],z=fa[y],原创 2016-06-23 11:07:19 · 364 阅读 · 0 评论 -
bzoj1058无限TLE(人傻自带常熟大的splay)
T了5个点的splay好吧,突然发现方法好像错了,不过学了一个splay_tree结构体的定义#include#include#include#include#include#include#include#define debug(x) cout<<#x<<"="<<x<<endlusing namespace std;const int N=1500010;con原创 2016-07-24 21:36:14 · 907 阅读 · 0 评论 -
bzoj1014火星人(字符串hash+splay)
表示刚开始1.没有选好mod数2.强制类型转换有问题,然后竟然wa了好几次,以后用9875321这个质数作为mod数其余就是代码能力的部分了#include#include#include#include#include#include#define debug(x) cout<<#x<<"="<<x<<endlusing namespace std;typed原创 2016-07-24 16:33:01 · 471 阅读 · 0 评论 -
bzoj1500维修序列(splay)
#include#include#include#include#include#include#include#define debug(x) cout<<#x<<"="<<x<<endl using namespace std;const int inf=0x3f3f3f3f;const int maxn=700100;int s[maxn*4],top=0;//回收栈原创 2016-07-23 21:21:51 · 413 阅读 · 1 评论 -
codevs 4543//bzoj3224(普通平衡树,聚合模板)
您需要写一种数据结构(可参考题目标题,但是这句话其实并没有什么用233),来维护一些数,其中需要提供以下操作:1. 插入x数2. 删除x数(若有多个相同的数,因只删除一个)3. 查询x数的排名(若有多个相同的数,因输出最小的排名)4. 查询排名为x的数5. 求x的前驱(前驱定义为小于x,且最大的数)6. 求x的后继(后继定义为大于x,且最小的数)#include#原创 2016-07-17 19:30:58 · 282 阅读 · 0 评论 -
bzoj1251(splay序列操作)
表示只是练一练手的题,但是,对于splay这种数据结构来说,一定要注意细节!!!such as,这道题当中是有可能出现负数的的情况中,求最大值,那么如果mx【0】等于0的话就有可能会出现bug(实际上就会出现,就这样wa了一次)所以splay就要尤其考虑0的情况,这种是怎么出现的呢?因为在updata的时候并没有判断是否有这个孩子(实际上updata的时候判断一下,也可以,就像我的原创 2016-08-22 19:59:39 · 378 阅读 · 0 评论