作者:kanate,发表于 Fri Sep 05 2025。
$\text{namespace}$ 是 __gnu_pbds
,头文件可以直接 #include<bits/extc++.h>
,不过 devcpp 用不了,只能 #include<ext/pb_ds/assoc_container.hpp>
以及对应的头文件,迭代器都是 $\text{point_iterator}$。
根据别人以及自己的 $\text{benchmark}$ 来说 $\text{hash_table}$ 表现很优秀,非构造数据卡点常还是要写的。
#include<ext/pb_ds/hash_policy.h>
gp_hash_table<int,int>
,当 $\text{unordered_set}$ 用的话是 gp_hash_table<int,nulltype>
用配对堆,支持 $O(1)\ \text{push join}$,$O(\log)\ \text{erase modify}$ 。
#include<ext/pb_ds/priority_queue.h>
__gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag>
用红黑树,相比 $\text{set}$ 支持 $\text{kth rank join split}$ ,和 $\text{fhq_treap}$ 的常数差不多,常数较大。
#include<ext/pb_ds/tree_policy.h>
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
reference
:pbds库学习笔记 - 知乎
Copyright © 2024 LVJ, Open-Source Project. 本站内容在无特殊说明情况下均遵循 CC-BY-SA 4.0 协议,内容版权归属原作者。