ibrahimsherif's blog

By ibrahimsherif, history, 5 months ago, In English,


Hi, i am trying to solve this problem using SQRT decomposition but i am getting TLE, how can it be optimized more or is my approach wrong.

Here is my code: https://ideone.com/tnuvKA

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

5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I think you got TLE because you were doing binary search on each block. You can speed it up by using MO's Algorithm + Compression.