hdu3436 Queue-jumpers(Splay)】的更多相关文章

Double Queue 默写splay板子 很多细节问题... #include<cstdio> #include<iostream> using namespace std; #define maxn 1000005 int root; ; ],par[maxn]; int cnt[maxn],size[maxn]; int val[maxn],dat[maxn]; void pushup(int x) { size[x]=cnt[x]+size[ch[x][]]+size[c…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3436 树状数组做法<猛戳> Splay tree的经典题目,有删除和移动操作.首先要离散化各个点,而且对于没有区间还要缩点.对于Top操作,先把目标节点删除,然后移到最左端.Query操作,Splay(tar,0),然后直接访问size.对于Rank操作,通过size产找即可.注意,在每次更新后,都要把处理过的节点都要Splay(tar,0)才能保证复杂度为O(log n),因为这样才能方便下次的…
Description The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped with a modern computing environment provided by IBM Romania, and using modern information technologies. As usual, each client of the bank i…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3411    Accepted Submission(s): 923 Problem Description Ponyo and Garfield are waiting outside the box-office for their favorite movie. Because q…
#include<stdio.h> #include<string.h> ; ],data[N],id[N],fa[N],size,root; void Rotate(int x,int w){//0:左旋 1:右旋 int y=fa[x]; t[y][!w]=t[x][w]; if(t[x][w]) fa[t[x][w]]=y; fa[x]=fa[y]; ]==y]=x; t[x][w]=y; fa[y]=x; } void Splay(int x,int y){ while(f…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4441 题意:一个数列,三种操作:(1)插入:找到没在当前数列中的最小的正整数i,将其插在位置p之后,并将-i插入某个位置使得满足先进先出(i表示进,-i表示出),这个位置尽量靠右:(2)删除:删掉数字i以及-i:(3)询问:查询i和-i之间的数字的和. 思路:对于没在数列中的数字可以用一个set直接维护.i的插入是正常的splay操作.对于-i的插入,我们首先找到i之前有几个正数,比如有x个,那么-…
题目 https://codeforces.com/problemset/problem/38/G 题意: 一些人按顺序进入队列,每个人有两个属性,地位$A$和能力$C$ 每个人进入时都在队尾,并最多可以和前一位互换$C$次,如果前一位的地位高于自己,则无法继续互换. 最终一次性输出整个队列 题解: splay维护动态的队列 可以用类似权值线段树的思维去考虑 对于每个点,保存其子节点的最大值,自身的值,与子树的大小 对于每次插入时,若能跨过整颗右子树与当前节点,则向左走,否则向右 可以保证整个子…
The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped with a modern computing environment provided by IBM Romania, and using modern information technologies. As usual, each client of the bank is identified…
Queue-jumpers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1821    Accepted Submission(s): 425 Problem Description Ponyo and Garfield are waiting outside the box-office for their favorite mov…
Description 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 2 3 4 1 Input 第一行为n,m n表示初始序列有n个数,这个序列依次是(1,2……n-1,n)  m表示翻转操作次数 接下来m行每行两个数[l,r] 数据保证 1<=l<=r<=n Output 输出一行n个数字,表示原始序列经过m次变换后的结果 Sample Input 5 3 1 3…