| 29 | root = nullptr; |
| 30 | } |
| 31 | void split(node *t, int pos, node *&l, node *&r) { |
| 32 | if (t == nullptr) { |
| 33 | l = r = nullptr; |
| 34 | return; |
| 35 | } |
| 36 | if (t->pos < pos) { |
| 37 | split(t->r, pos, l, r); |
| 38 | t->r = l; |
| 39 | l = t; |
| 40 | } else { |
| 41 | split(t->l, pos, l, r); |
| 42 | t->l = r; |
| 43 | r = t; |
| 44 | } |
| 45 | t->pull(); |
| 46 | } |
| 47 | node* merge(node *l, node *r) { |
| 48 | if (!l || !r) return l ? l : r; |
| 49 | if (l->key < r->key) { |