diff options
Diffstat (limited to 'datastructures/pbds.cpp')
| -rw-r--r-- | datastructures/pbds.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/datastructures/pbds.cpp b/datastructures/pbds.cpp index c2b44cc..a0e5383 100644 --- a/datastructures/pbds.cpp +++ b/datastructures/pbds.cpp @@ -1,10 +1,19 @@ +#include <ext/pb_ds/priority_queue.hpp> +template<typename T> +using pQueue = __gnu_pbds::priority_queue<T>; //<T, greater<T>> +auto it = pq.push(5); // O(1) +pq.modify(it, 6); // O(log n) +pq.erase(it); // O(log n) +pq.join(pq2); // O(1) +pq.swap(pq2); // O(1) + #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; -// T.order_of_key(x): number of elements strictly less than x -// *T.find_by_order(k): k-th element +T.order_of_key(x); // number of elements strictly less than x +auto it = T.find_by_order(k); // k-th element template<typename T> struct chash { |
