Problem Info
I’m doing Sateliti from the Gold string hashing module.
My Work
My code is here.
It follows the approach here, using binary search and hashing to find the first position at which the two images differ.
For the hash, it uses 2D prefix sums and a modular inverse.
The problem is, this only passes the first two subtasks. I’m not sure how to pass the last one- it seems that the constant factor of my program is simply too large.
Is there a clever way to avoid calculating modular inverses or something? It seems that precalculating the powers and inverses takes up an extremely large chunk of the runtime.