From a867520b0ba8ce1a16eca0c477b841d356dbf7e5 Mon Sep 17 00:00:00 2001 From: Matuush Date: Wed, 9 Apr 2025 15:22:36 +0200 Subject: [PATCH] Delete removed lines --- treap.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/treap.hpp b/treap.hpp index 7eec0df..e4636f5 100644 --- a/treap.hpp +++ b/treap.hpp @@ -95,6 +95,7 @@ public: root = two.second; delete two.first; } + root = nullptr; } // Line insert @@ -122,7 +123,9 @@ public: // Line removal void remove(count_type k) { auto two = split(root, k+1); - two.first = split(two.first, k).first; + auto first_split = split(two.first, k); + delete first_split.second; + two.first = first_split.first; root = join(two); } void pop() {