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

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

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!

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