How to hash?

Revision en1, by larush, 2023-11-06 03:43:59

Hello

So I was solving this problem (here), and a hashing-based solution seemed obvious to me. It is enough to look at the hash of the changed substring and get the final hash of the modified string using the prefix and suffix. I do not know much about hashing, just a little about polynomial (or rolling) hash. But it seems that my hash isn't safe enough. I tried a few things, but with no luck:

Spoiler

I used the standard primes M = 1e9+9 and p = 31 initially, as I learned from cp-algo. I have no clue what I'm doing wrong.

I hope someone could assist me in this and help me understand hashing a little better. Cheers!

off by one

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English larush 2023-11-06 03:43:59 1351 Initial revision (published)