summaryrefslogtreecommitdiff
path: root/datastructures/pbds.cpp
blob: c2b44cce70d6f5239302aed9308f3f1e99a1d145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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>>;