This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub tatyam-prime/ICPC_notebook
#include "src/string/RollingHash.hpp"
RH rh(string s)
u64 rh.get(ll l, ll r)
// using u64 = uint64_t; const u64 mod = INF; u64 add(u64 a, u64 b) { a += b; if(a >= mod) a -= mod; return a; } u64 mul(u64 a, u64 b) { auto c = (__uint128_t)a * b; return add(c >> 61, c & mod); } random_device rnd; const u64 r = ((u64)rnd() << 32 | rnd()) % mod; struct RH { ll n; vector<u64> hs, pw; RH(string s) : n(sz(s)), hs(n + 1), pw(n + 1, 1) { rep(i, 0, n) { pw[i + 1] = mul(pw[i], r); hs[i + 1] = add(mul(hs[i], r), s[i]); } } u64 get(ll l, ll r) const { return add(hs[r], mod - mul(hs[l], pw[r - l])); } };
#line 1 "src/string/RollingHash.hpp" // using u64 = uint64_t; const u64 mod = INF; u64 add(u64 a, u64 b) { a += b; if(a >= mod) a -= mod; return a; } u64 mul(u64 a, u64 b) { auto c = (__uint128_t)a * b; return add(c >> 61, c & mod); } random_device rnd; const u64 r = ((u64)rnd() << 32 | rnd()) % mod; struct RH { ll n; vector<u64> hs, pw; RH(string s) : n(sz(s)), hs(n + 1), pw(n + 1, 1) { rep(i, 0, n) { pw[i + 1] = mul(pw[i], r); hs[i + 1] = add(mul(hs[i], r), s[i]); } } u64 get(ll l, ll r) const { return add(hs[r], mod - mul(hs[l], pw[r - l])); } };