Блог пользователя wrg0ababd

Автор wrg0ababd, 9 лет назад, По-английски

I understand that I'll get downvoted here, but maybe I'll get some help as well. I'm trying to solve 514C using hashing, as it's done in editorial, but why my submission gets WA on test 27?

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Most probably a false positive due to a hash collision. The hash function is probably telling your program that the string only has a single character changed, but multiple characters may have changed and the same hash value has been computed.

To avoid this, maintain a Map<Long, String> for each hash value -> string, then when you think you found a solution, double check that the difference is indeed one letter. See my submission for an example.