As far as I know, hashing is a powerful tool to compare two strings in O(1) but it has an error rate; especially in online contests, where I saw so many submissions were hacked because of it. Therefore, I have some questions:
- Should I use hashing in online contests, or it is only good for offline competitions? And if yes, how should I use it to both meet the time limit and make it difficult to hack?
- Are there any alternatives to hashing which can't be hacked that run in O(1) or O(log(n))?
I appreciate your time reading and answering my questions.








It's definitely viable in online competitions, and is difficult to hack if you use a randomized base and a large enough modulo/multiple moduli, see https://usaco.guide/gold/hashing