虽然叫做非旋treap但是飞旋treap很带感所以就用这个名字了(SB)

这个东西是真的好写......

主要的两个函数只有两个,rotate和splay,split和merge。

merge就是大家都熟悉的左偏树合并,线段树合并......注意不能swap(x, y)

split分为splitV和splitS,按权值分,按大小分。

 1 inline void splitS(int o, int k, int &x, int &y) {
 2     if(!o) {
 3         x = y = 0;
 4         return;
 5     }
 6     //pushdown(o);
 7     if(k <= siz[ls[o]]) {
 8         y = o;
 9         splitS(ls[y], k, x, ls[y]);
10     }
11     else {
12         x = o;
13         splitS(rs[x], k - siz[ls[o]] - 1, rs[x], y);
14     }
15     pushup(o);
16     return;
17 }
splitS

相关文章:

  • 2021-08-04
  • 2022-02-10
  • 2022-02-20
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-02-17
猜你喜欢
  • 2022-01-28
  • 2021-10-12
  • 2021-08-30
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-02-18
相关资源
相似解决方案