diff --git a/AGENTS.md b/AGENTS.md index ec31b50..e6ccb2b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ When adding or editing code here, optimize for contest usage first. - Prefer `ll` by default to reduce overflow debugging. - Use `int` only when clearly safe and beneficial (memory, bitset indexing, array indices, tight constraints). - Avoid implicit narrowing conversions. Cast explicitly at boundaries when mixing types. -- Prefer aliases from `common.hpp` (e.g., `pll`, `pii`) when they match exactly to reduce typing. +- Always use aliases from `common.hpp` (e.g., `pll`, `pii`) when they match exactly to reduce typing. ## Coding rules - Prefer straightforward implementations over heavy abstractions. diff --git a/src/1-ds/erasable_pq.cpp b/src/1-ds/erasable_pq.cpp index 4b148c6..023d212 100644 --- a/src/1-ds/erasable_pq.cpp +++ b/src/1-ds/erasable_pq.cpp @@ -1,4 +1,9 @@ #include "../common/common.hpp" +// Erasable priority queue (lazy deletion). +// what: priority_queue with erase by value (multiset-like) +// time: push/pop/erase amortized O(log n), top O(1) amortized, memory: O(n) +// constraint: erase only existing values, duplicates ok +// usage: erasable_pq pq; pq.push(x); pq.erase(x); ll v = pq.top(); pq.pop(); template > struct pq_set { priority_queue, O> q, del;