From d6e22b641b93d3611d7709e1ca64b6f4d8c48568 Mon Sep 17 00:00:00 2001 From: Matuush Date: Fri, 28 Mar 2025 16:52:19 +0100 Subject: [PATCH] Made treap size comparisons inclusive --- file.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/file.hpp b/file.hpp index 0eaac96..dd44f23 100644 --- a/file.hpp +++ b/file.hpp @@ -32,7 +32,7 @@ public: two_lines split(line *l, count_type k) { if(l == nullptr) return {nullptr, nullptr}; - if(get_size(l->left) > k) { + if(get_size(l->left) >= k) { // In the left subtree auto two = split(l->left, k); l->size -= get_size(two.first); @@ -45,6 +45,7 @@ public: return {l, two.second}; } } + // Join two treaps // Hopefully with working sizes line* join(line *a, line *b) { @@ -63,6 +64,7 @@ public: } } line* join(two_lines two) { return join(two.first, two.second); } + // Find k-th line of file line* find(line* l, count_type k) { if(l == nullptr) return nullptr;