diff options
| author | Yidi <noob999noob999@gmail.com> | 2024-05-14 17:01:58 +0200 |
|---|---|---|
| committer | Yidi <noob999noob999@gmail.com> | 2024-05-14 17:01:58 +0200 |
| commit | 6adb7d98bccc23cc8829611ff4b1831708932cd5 (patch) | |
| tree | dab80dc85649b0e5bf9825d3712b2c81153c07aa /datastructures/pbds.cpp | |
| parent | 98aa28427350e72cb9abe4071c0c6b6870b7e6cc (diff) | |
add missing files
Diffstat (limited to 'datastructures/pbds.cpp')
| -rw-r--r-- | datastructures/pbds.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/datastructures/pbds.cpp b/datastructures/pbds.cpp new file mode 100644 index 0000000..c2b44cc --- /dev/null +++ b/datastructures/pbds.cpp @@ -0,0 +1,18 @@ +#include <ext/pb_ds/assoc_container.hpp> +using namespace __gnu_pbds; +template<typename T> +using Tree = tree<T, null_type, less<T>, rb_tree_tag, + tree_order_statistics_node_update>; +// T.order_of_key(x): number of elements strictly less than x +// *T.find_by_order(k): k-th element + +template<typename T> +struct chash { + const uint64_t C = ll(2e18 * acos(-1)) | 199; // random odd + size_t operator()(T o) const { + return __builtin_bswap64(hash<T>()(o) * C); +}}; +template<typename K, typename V> +using hashMap = gp_hash_table<K, V, chash<K>>; +template<typename T> +using hashSet = gp_hash_table<T, null_type, chash<T>>; |
