Sir ,
- i am unable to understand where we used square root decomposition in this problem . All i see is mo 's algo??
- Also why we used block in comparator for sorting queries , if we can sort it on the basis of l and r ?
Sir ,
Mo’s algorithm is based on sqrt decomposition. (Read more, here)
I think you have misunderstood the ordering of queries in Mo’s, it is not simple sorting of ascending pairs, rather:
(Maybe this is the bug in your code that is causing WA in SPOJ).