library

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

View the Project on GitHub kk2a/library

:heavy_check_mark: random/hash.hpp

Depends on

Required by

Verified with

Code

#ifndef KK2_RANDOM_HASH_HPP
#define KK2_RANDOM_HASH_HPP 1

#include <algorithm>
#include <array>
#include <cassert>

#include "../math_mod/primitive_root_64bit.hpp"
#include "../modint/modint_2_61m1.hpp"
#include "gen.hpp"

namespace kk2 {

namespace random {

template <int NUM> struct Hash : std::array<ModInt2_61m1, NUM> {
    using mint = ModInt2_61m1;
    using std::array<mint, NUM>::operator[];
    using u64 = unsigned long long;

    Hash() : std::array<mint, NUM>() {}

    template <class T, is_integral_t<T> * = nullptr> Hash(T x) {
        std::fill(this->begin(), this->end(), mint(x));
    }

    static Hash get_base() {
        Hash base;
        for (int i = 0; i < NUM; i++) base[i] = primitive_root_mint<ModInt2_61m1>();
        return base;
    }

    Hash &operator+=(const Hash &rhs) {
        for (int i = 0; i < NUM; i++) (*this)[i] += rhs[i];
        return *this;
    }
    Hash &operator-=(const Hash &rhs) {
        for (int i = 0; i < NUM; i++) (*this)[i] -= rhs[i];
        return *this;
    }
    Hash &operator*=(const Hash &rhs) {
        for (int i = 0; i < NUM; i++) (*this)[i] *= rhs[i];
        return *this;
    }
    Hash &operator/=(const Hash &rhs) {
        for (int i = 0; i < NUM; i++) (*this)[i] /= rhs[i];
        return *this;
    }

    Hash operator+(const Hash &rhs) const { return Hash(*this) += rhs; }
    Hash operator-(const Hash &rhs) const { return Hash(*this) -= rhs; }
    Hash operator*(const Hash &rhs) const { return Hash(*this) *= rhs; }
    Hash operator/(const Hash &rhs) const { return Hash(*this) /= rhs; }
    Hash operator+() const { return *this; }
    Hash operator-() const { return Hash(0) - *this; }

    Hash pow(u64 n) const {
        Hash r;
        for (int i = 0; i < NUM; i++) r[i] = (*this)[i].pow(n);
        return r;
    }

    Hash inv() const {
        Hash r;
        for (int i = 0; i < NUM; i++) r[i] = (*this)[i].inv();
        return r;
    }
};

} // namespace random

} // namespace kk2

#endif // KK2_RANDOM_HASH_HPP
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
  [Previous line repeated 1 more time]
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 312, in update
    raise BundleErrorAt(path, i + 1, "#pragma once found in a non-first line")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: type_traits/integral.hpp: line 4: #pragma once found in a non-first line
Back to top page