Enatsu__8's blog

By Enatsu__8, history, 10 days ago, In English

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 have written this implementation but it's giving TLE

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

Thanks!

  • Vote: I like it
  • +3
  • Vote: I do not like it