Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void precompute_hashes( std::string Str )
- {
- const uint n = Str.size();
- Hi.resize(n);
- Hi[0] = Str[0];
- for (size_t i = 1; i < n; i++)
- Hi[i] = Hi[i - 1] * x + static_cast<int64>(Str[i - 1]);
- }
- inline int64 hash( uint l, uint r )
- {
- return Hi[r] - Hi[l] * int64(powl(x, r - l));
- }
- ....
- x = 31
- ...
- Ans.emplace_back(hash(a - 1, b - 1) == hash(c - 1, d - 1)
- ? "Yes"
- : "No");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement