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

Автор vinayaka, история, 10 месяцев назад, По-английски

Hello, I'm trying to solve the problem movie festival II on cses problemset.

This is my code

My code

It gives AC on 9 cases and WA on 4.

This is success code from USACO Guide forum.

Success code

What am I doing wrong? Isn't set.upper_bound comparison same and pq.top in mine? Can anyone help in writing success PQ code?

Полный текст и комментарии »

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

Автор vinayaka, история, 13 месяцев назад, По-английски

Hi,

My knowledge on String algorithms is poor so I am studying it now.

I solved 271D - Good Substrings using a Trie, but I am trying to solve it using hashing.

I am able to calculate a polynomial rolling hash and compare substrings based on the hash, but my solution is getting WA on test 8 (230797737). I am thinking this is because of collisions, since the expected answer is also pretty high.

I read a topic on double polynomial rolling hash to reduce probability of collisions. I understand that if we use two hashes of order 10^9 then probability will be less because it is equivalent to using a 10^18 modulo.

I am unable to understand how to implement it.

Can anyone help?

Please point me towards an article/blog/submission that has code on implementing it.

Thank you.

Полный текст и комментарии »

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