HDU 3487 Splay】的更多相关文章

给定两种操作,一种是把一个数列的某一段切下来插到剩余数列的某一个位置上. 一种是翻转操作,把数列的某一段进行翻转. 都是Splay的基本操作.标准的Rotateto调整出 [a,b]区间.然后对[a,b]区间修改parent标记和child标记.然后记住PushUp把修改标记推到树根上.简单一点就直接对某个节点spaly(x,0)就OK! 1: #include <cstdio> 2: #include <iostream> 3: #include <vector> 4…
Play with Chain Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6779    Accepted Submission(s): 2678 Problem Description YaoYao is fond of playing his chains. He has a chain containing n diamond…
题目大意 给一个数列,初始时为 1, 2, 3, ..., n,现在有两种共 m 个操作 操作1. CUT a b c 表示把数列中第 a 个到第 b 个从原数列中删除得到一个新数列,并将它添加到新数列中第 c 个数的后面 操作2. FLIP a b 表示把数列中第 a 个数到第 b 个数翻转 经过 m 个操作之后,输出这个数列 1≤n, m≤3*100000 做法分析 这题也不好用线段树做,用 Splay 很快就搞出来了 对于"操作1. CUT a b c" ,只需要将 a-1 旋转…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3487 YaoYao is fond of playing his chains. He has a chain containing n diamonds on it. Diamonds are numbered from 1 to n.At first, the diamonds on the chain is a sequence: 1, 2, 3, …, n.He will perform t…
Queue-jumpers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3139    Accepted Submission(s): 848 Problem Description Ponyo and Garfield are waiting outside the box-office for their favorite mo…
Looploop Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1651    Accepted Submission(s): 517 Problem Description XXX gets a new toy named Looploop. The toy has N elements arranged in a loop, an…
http://acm.hdu.edu.cn/showproblem.php?pid=3487 题意:有两种操作:1.Flip l r ,把 l 到 r 这段区间 reverse.2.Cut a b c ,把 a 到 b 这段区间切掉,再把这段区间接到切掉后的第 c 个数的后面. 思路:做完了上一道变态题目,做这道题目如鱼得水.Cut的时候就是把a 到 b 放到keytree的位置,记录一下当前keytree的值,然后切掉,再把切掉后的第 c 个数转到 root 的位置,再把这个记录的值重新连接回…
Play with Chain Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) [Problem Description] YaoYao is fond of playing his chains. He has a chain containing n diamonds on it. Diamonds are numbered from 1 to n. At first, t…
1-n的序列,有两种操作: 1,将一段区间翻转 2,将一段区间切下来放到剩余序列的第C个数后 采用延迟更新的方法维护区间的翻转,并维护一个size域. 添加一个最大点和一个最小点,防止出界 翻转时,将第L-1个点伸展到跟,再将第R+1个点伸展到L-1的右子树,这时R+1的左子树就是要翻转的区间,加上一个标记. 切区间时,跟翻转操作差不多,只是不加标记.然后找到C+1和C,将C伸展到根,C+1伸展到C的右子树,此时C+1的左子树就是要插入的位置. 其实我说了这么多并没有什么卵用....最后还是得自…
Play with Chain Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2783    Accepted Submission(s): 1141 Problem Description YaoYao is fond of playing his chains. He has a chain containing n diamond…