是NOI2003Editor的一个子任务

 #include <cstdio>
#include <vector>
#define maxn 100010
using namespace std; struct Splay {
int pre[maxn], son[maxn][], siz[maxn], rev[maxn], root; void update( int nd ) {
siz[nd] = siz[son[nd][]]+siz[son[nd][]]+;
}
void pushdown( int nd ) {
if( rev[nd] ) {
swap( son[nd][], son[nd][] );
if( son[nd][] ) rev[son[nd][]] ^= ;
if( son[nd][] ) rev[son[nd][]] ^= ;
rev[nd] = ;
}
}
int build( int lf, int rg, int p ) {
if( lf>rg ) return ;
int mid = (lf+rg)>>;
pre[mid] = p;
rev[mid] = ;
son[mid][] = build( lf, mid-, mid );
son[mid][] = build( mid+, rg, mid );
update( mid );
return mid;
}
void init( int n ) {
root = build( , n+, );
}
void rotate( int nd, int d ) {
int p = pre[nd];
int s = son[nd][!d];
int ss = son[s][d]; son[nd][!d] = ss;
son[s][d] = nd;
if( p ) son[p][ nd==son[p][] ] = s;
else root = s; pre[nd] = s;
pre[s] = p;
if( ss ) pre[ss] = nd; update( nd );
update( s );
}
void splay( int nd, int top ) {
while( pre[nd]!=top ) {
int p = pre[nd];
int nl = nd==son[p][];
if( pre[p]==top ) {
rotate( p, nl );
} else {
int pp = pre[p];
int pl = p==son[pp][];
if( nl==pl ) {
rotate( pp, pl );
rotate( p, nl );
} else {
rotate( p, nl );
rotate( pp, pl );
}
} }
}
int find( int pos ) {
int nd = root;
while() {
pushdown( nd );
int ls = siz[son[nd][]];
if( pos<=ls ) {
nd = son[nd][];
} else if( pos>=ls+ ) {
nd = son[nd][];
pos -= ls+;
} else {
splay( nd, );
return nd;
}
}
}
void reverse( int lf, int rg ) {
int lnd = find(lf-);
int rnd = find(rg+);
splay( lnd, );
splay( rnd, lnd );
rev[son[rnd][]] ^= ;
pushdown( son[rnd][] );
splay( son[rnd][], );
}
int get( int pos ) {
return find(pos);
}
}; int n, m;
Splay T;
int main() {
scanf( "%d%d", &n, &m );
T.init( n );
for( int i=,lf,rg; i<=m; i++ ) {
scanf( "%d%d", &lf, &rg );
T.reverse( lf+, rg+ );
}
for( int i=; i<=n+; i++ )
printf( "%d ", T.get(i)- );
}

bzoj 3223 文艺平衡树 Splay 打标志的更多相关文章

  1. bzoj 3223 文艺平衡树 - Splay

    3223: Tyvj 1729 文艺平衡树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 3884  Solved: 2235[Submit][Sta ...

  2. bzoj 3223 文艺平衡树 splay 区间翻转

    Tyvj 1728 普通平衡树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 17715  Solved: 7769[Submit][Status][ ...

  3. [题解]bzoj 3223 文艺平衡树

    3223: Tyvj 1729 文艺平衡树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 3884  Solved: 2235[Submit][Sta ...

  4. BZOJ 3223 文艺平衡树 [codevs3303翻转区间]

    AC通道:http://www.lydsy.com/JudgeOnline/problem.php?id=3223 通道2:http://codevs.cn/problem/3303/ 题目分析: 我 ...

  5. BZOJ 3223 文艺平衡树

    Description   您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 2  ...

  6. 【阶梯报告】洛谷P3391【模板】文艺平衡树 splay

    [阶梯报告]洛谷P3391[模板]文艺平衡树 splay 题目链接在这里[链接](https://www.luogu.org/problemnew/show/P3391)最近在学习splay,终于做对 ...

  7. luoguP3391[模板]文艺平衡树(Splay) 题解

    链接一下题目:luoguP3391[模板]文艺平衡树(Splay) 平衡树解析 这里的Splay维护的显然不再是权值排序 现在按照的是序列中的编号排序(不过在这道题目里面就是权值诶...) 那么,继续 ...

  8. BZOJ 3223: Tyvj 1729 文艺平衡树(splay)

    速度居然进前十了...第八... splay, 区间翻转,用一个类似线段树的lazy标记表示是否翻转 ------------------------------------------------- ...

  9. bzoj 3223: Tyvj 1729 文艺平衡树 (splay)

    链接: https://www.lydsy.com/JudgeOnline/problem.php?id=3223 题面: 3223: Tyvj 1729 文艺平衡树 Time Limit: 10 S ...

随机推荐

  1. ubuntu下中文输入法的配置,建议用fcitx

    Fcitx [ˈfaɪtɪks] 是一个支持扩展的输入法框架.它有自己维护的三个输入法,拼音,区位和码表:还支持其他引擎,rime 中州韵,google-pinyin,sunpinyin.Fcitx ...

  2. JVM的分区+查看GC对象是否存活+3种GC算法+7种垃圾收集器+如何减少GC次数

    一.JVM的分区:   1.程序计数器(私有) 程序计数器是一块较小的内存分区,你可以把它看做当前线程所执行的字节码的指示器. 在虚拟机的概念模型里,字节码解释器工作时,就是通过改变计数器的值来选择下 ...

  3. 表格中上移下移置顶的js操作

    <script> $(function(){  //上移  var $up = $(".up")  $up.click(function() {   var $tr = ...

  4. /etc/issue 与 /etc/issue.net 文件,telnet登陆前的显示

    在使用文本设备(关于文本设备的例子,见下面的说明)登录Linux系统之前,系统会显示一条被称作“issue”的消息: 若是通过本地文本设备(如本地终端,本地虚拟控制台等)登录,则该信息存放与/etc/ ...

  5. 主机名/etc/hosts文件的作用

    1,/etc/hosts,主机名ip配置文件. # Do not remove the following line, or various programs # that require netwo ...

  6. hexdump related.

    hexdump format strings Tue 13 December 2005 In tips. Ian Wienand More from the "things you'd le ...

  7. appium---【Mac】Appium-Doctor提示WARN:“ ios_webkit_debug_proxy cannot be found”解决方案

    “ ios_webkit_debug_proxy cannot be found”报错截图如下: 解决方案: 打开terminal终端,分别输入执行结束,再次运行appium-doctor即可看到运行 ...

  8. AC日记——小A和uim之大逃离 II 洛谷七月月赛

    小A和uim之大逃离 II 思路: spfa: 代码: #include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f ...

  9. 在ubuntu下安装kaldi基本步骤

    注:最近在学习kaldi语音识别工具,在安装过程中遇到了许多问题,在此记录,以备后需. 在一开始,我看了这篇博客(http://blog.topspeedsnail.com/archives/1001 ...

  10. C# asp.net 实现导出Excel

    原文地址:传送门 这段时间用到了导出Excel的功能,这个功能还是比较常用的,我常用的有两个方法,现在整理一下,方便以后查看. 1.实现DataTable数据导出到本地,需要自己传进去导出的路径. / ...