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 2 "random/base.hpp"

u64 RNG_64() {
  static uint64_t x_
      = uint64_t(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) { return RNG_64() % lim; }

ll RNG(ll l, ll 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