-
MinMaxPQ232's competitive-programming templates. 2024. 10. 3. 19:52
need PriorityQueuePair.
template <typename T> struct MinMaxPQ { PriorityQueuePair<T, std::greater<>> minq; PriorityQueuePair<T> maxq; [[nodiscard]] int size() const { return minq.size(); } [[nodiscard]] bool empty() const { return size() == 0; } void insert(const T& x) { minq.insert(x); maxq.insert(x); } [[nodiscard]] const T& getMin() const { assert(!empty()); return minq.get(); } [[nodiscard]] const T& getMax() const { assert(!empty()); return maxq.get(); } void erase(const T& x) { minq.erase(x); maxq.erase(x); } };
'232's competitive-programming templates.' 카테고리의 다른 글
(useless) BipartiteMatching (slow) (0) 2024.10.22 Dinic (0) 2024.10.22 Centroid, CentroidTree (0) 2024.09.26 polynomial (0) 2024.09.21 lcs_algo (0) 2024.09.17