library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub maspypy/library

:heavy_check_mark: random/hash_pair.hpp

Depends on

Required by

Verified with

Code

#include "random/base.hpp"

template <typename T>
u64 hash_pair(pair<T, T> X) {
  static ll hash_base = 0;
  if (hash_base == 0) hash_base = RNG_64();
  return hash_base * X.fi + X.se;
}
#line 1 "random/base.hpp"

u64 RNG_64() {
  static u64 x_ = u64(chrono::duration_cast<chrono::nanoseconds>(
                      chrono::high_resolution_clock::now().time_since_epoch())
                          .count()) *
                  10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}

u64 RNG(u64 lim) {
  assert(lim > 0);
  return RNG_64() % lim;
}

ll RNG(ll l, ll r) {
  assert(l < r);
  return l + RNG_64() % (r - l);
}
#line 2 "random/hash_pair.hpp"

template <typename T>
u64 hash_pair(pair<T, T> X) {
  static ll hash_base = 0;
  if (hash_base == 0) hash_base = RNG_64();
  return hash_base * X.fi + X.se;
}
Back to top page