uva 11922 Permutation Transformer 排列变换 Splay 维护序列 翻转操作(二)

2014-11-24 02:42:01 · 作者: · 浏览: 3
();///pushdown
out(rt->ch[0]);
if (rt->v > 0) printf("%d\n", rt->v);
out(rt->ch[1]);
// delete rt;
// rt = null;
}
void debug(Node* &o)
{
if(o == null) return ;
printf("%d(",o->v);
if(o->ch[0]!=null) printf("%d,",o->ch[0]->v);
else printf("null,");
if(o->ch[1]!=null) printf("%d",o->ch[1]->v);
else printf("null");
puts(")");
if(o->ch[0]!=null) debug(o->ch[0]);
if(o->ch[1]!=null) debug(o->ch[1]);
}
}sp;
int main ()
{
int n, m;
int x, y;
while (~scanf("%d%d", &n, &m))
{
sp.init();
sp.build(sp.root, n);
for (int i = 1; i <= m; i++)
{
scanf("%d%d", &x, &y);
sp.solve(x, y);
}
sp.out(sp.root);
}
return 0;
}