From 5d314398b80b936ad31713dc8ed8663038dde315 Mon Sep 17 00:00:00 2001 From: manoflearning <77jwk0724@gmail.com> Date: Mon, 29 Dec 2025 19:18:42 +0900 Subject: [PATCH 1/2] feat: add multiset pbds --- src/1-ds/pbds.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/1-ds/pbds.cpp b/src/1-ds/pbds.cpp index 3ed73ae..3f4c488 100644 --- a/src/1-ds/pbds.cpp +++ b/src/1-ds/pbds.cpp @@ -2,7 +2,15 @@ #include #include using namespace __gnu_pbds; -using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; -ordered_set st; +using pbds = tree, rb_tree_tag, tree_order_statistics_node_update>; +pbds st; st.order_of_key(x); // number of elements strictly less than x -st.find_by_order(x); // value of xth element (0-based) \ No newline at end of file +st.find_by_order(x); // value of xth element (0-based) + +// multiset pbds (use "less_equal" and custom "m_erase") +using multi_pbds = tree, rb_tree_tag, tree_order_statistics_node_update>; +void m_erase(multi_pbds &OS, int val){ + int index = OS.order_of_key(val); + multi_pbds::iterator it = OS.find_by_order(index); + OS.erase(it); +} From 14389194d874bd6794b279865c9bd63a02292ade Mon Sep 17 00:00:00 2001 From: manoflearning <77jwk0724@gmail.com> Date: Mon, 29 Dec 2025 19:21:07 +0900 Subject: [PATCH 2/2] fix --- src/1-ds/pbds.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/1-ds/pbds.cpp b/src/1-ds/pbds.cpp index 3f4c488..87af3a4 100644 --- a/src/1-ds/pbds.cpp +++ b/src/1-ds/pbds.cpp @@ -9,8 +9,8 @@ st.find_by_order(x); // value of xth element (0-based) // multiset pbds (use "less_equal" and custom "m_erase") using multi_pbds = tree, rb_tree_tag, tree_order_statistics_node_update>; -void m_erase(multi_pbds &OS, int val){ - int index = OS.order_of_key(val); - multi_pbds::iterator it = OS.find_by_order(index); - OS.erase(it); +void m_erase(multi_pbds &OS, int val) { + int index = OS.order_of_key(val); + multi_pbds::iterator it = OS.find_by_order(index); + OS.erase(it); }