Comments
On fmota → Grand Prix of Saratov, 5 years ago
0

Got it thanks!

Thank you very much! I think I get what you're saying, Ill try implementing it!

On fmota → Grand Prix of Saratov, 5 years ago
0

I am getting TLE on TC-15 by using rolling hashes for problem K.

What I did was precompute the hash function for every prefix of S and for every query compute the hash for query substring P and traverse through S and greedily pick matches. I also stored the answers for every query in a map to avoid recomputation. What am I missing?

118728564

Tet brezhart Thanks for replying.

As you guys suggested, I tried using greedy with rolling-hash but still got TLE. The constraints seem to be too high for an O(Q. N) algorithm. Any hint on how to improve this? Here is the code for reference: Code

Thanks! I get my mistake now

Can someone help me find the loophole in this approach for Problem C?

It keeps failing Test 2

112630518

Lmao

In the editorial solution for C, is there a specific reason for not just using 'return' incase the given string is already beautiful or the case when no beautiful string is possible? They used 'continue' and a flag to skip the 'for loop'.

Thank you! I had the same exact problem.