GerONSo

Untitled

Jun 9th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. pair<treap*, treap*> split(treap *a, int k) {
  2. if(a == nullptr) return {nullptr, nullptr};
  3. // cerr << (a->left == nullptr) << '\n';
  4. int l = ((a->left == nullptr) ? -1 : a->left->sz);
  5. if(k <= l) {
  6. pair<treap*, treap*> kek = split(a->left, k);
  7. a->left = kek.y;
  8. update(a);
  9. return {kek.x, a};
  10. }
  11. else {
  12. pair<treap*, treap*> kek = split(a->right, k - l - 1);
  13. a->right = kek.x;
  14. update(a);
  15. return {a, kek.y};
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment