版本比较
常用 STL 大全(?)
正文
增加 2 行删除 2 行
309 行未改动全部展开310311312313314314315316317318225 行未改动全部展开54454554654754854854955055155269 行未改动309 行未改动全部展开::cute-table| 接口 | 功能说明 | 时间复杂度||:-----------------------:|:---------------------------------:|:--------:|| `priority_queue<T> pq` | 大顶堆(默认基于 `vector`) | $O(1)$ || `priority_queue<T, vector<T>, greater<T>> pq` | 小顶堆 | ^ | | `priority_queue<T, vector<T>, greater<T>> pq` | 小顶堆 | ^ || `pq.push(x)` | 入堆 | $O(\log n)$ || `pq.pop()` | 出堆(删除堆顶, | ^ || `pq.top()` | 获取堆顶元素 | $O(1)$ || `pq.size()` / `pq.empty()` | 基础操作 | ^ |225 行未改动全部展开// 按个位数排序sort(arr.begin(), arr.end(), [](int a, int b){ return a%10 < b%10; });// 过滤 ≤3 的元素int threshold = 3;arr.erase(remove_if(arr.begin(), arr.end(), arr.erase(remove_if(arr.begin(), arr.end(), [threshold](int x){ return x <= threshold; }), arr.end());```
## 五、常用工具函数与头文件69 行未改动