版本比较
CSP-S 初赛复习笔记
正文
增加 1 行删除 1 行
308 行未改动全部展开309310311312313313314315316317845 行未改动全部展开308 行未改动全部展开
| 函数 | 用法 | 作用 | 复杂度 || :----------------- | :----------------------------------------------- | :-------------------------------- | :---------: || `next_permutation` | `next_permutation(a.begin(), a.end())` | 变为字典序下一个排列 | $O(n)$ || `prev_permutation` | `prev_permutation(a.begin(), a.end())` | 变为字典序下一个排列 | $O(n)$ || `prev_permutation` | `prev_permutation(a.begin(), a.end())` | 变为字典序上一个排列 | $O(n)$ || `unique` | `unique(a.begin(), a.end())` | 将相邻重复元素移到末尾 | $O(n)$ || `nth_element` | `nth_element(a.begin(), a.begin() + k, a.end())` | 使第 $k$ 个元素处于排序后的正确位置 | 平均 $O(n)$ || `lower_bound` | `lower_bound(a.begin(), a.end(), x)` | 第一个 $\ge x$ 的位置 | $O(\log n)$ || `upper_bound` | `upper_bound(a.begin(), a.end(), x)` | 第一个 $>x$ 的位置 | $O(\log n)$ |845 行未改动全部展开