手写HASH模版
手写 \(HASH\)
可以是 \(ump\) 能够用 \(pair\)。
struct Hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ x >> 30) * 0xbf58476d1ce4e5b9;
x = (x ^ x >> 27) * 0x94d049bb133111eb;
return x ^ x >> 31;
}
static size_t get(const uint64_t x) {
static const ui64 FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
template <typename T>
size_t operator() (T x) const {
return get(std::hash<T>()(x));
}
template <typename F, typename S>
size_t operator() (pair<F, S> p) const {
return get(std::hash<F>()(p.first)) ^ std::hash<S>()(p.second);
}
};
unordered_map<PI, i64, Hash> mp;

浙公网安备 33010602011771号