[Need help] SPOJ KQUERY with Fractional Cascading

Revision en1, by Enatsu__8, 2024-12-13 13:35:55

Hi all, I am trying to solve this question from SPOJ and to solve this I created a segment tree and at each node stored the sorted array and then for each query did binary search over all the nodes, I visited during query but this leads to O((log n)^2)/query, thus getting TLE.

I have seen that I could solve it via offline querying but I want to find if it can be done via fractional cascading or not.

I am having hard time coming up with the solution, would really appreciate if someone could help.

Thanks!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Enatsu__8 2024-12-13 15:13:28 94
en1 English Enatsu__8 2024-12-13 13:35:55 609 Initial revision (published)