CHANOQ [Unofficial Editorial] (Chef And Odd queries) FEB LONG

on what i learnt from Mo’s algorithm,i implemented this… getting SIGSEGV and TLE …
Surely something is wrong with my approach… Could anyone care to point it out…
my solution -https://www.codechef.com/viewsolution/17485189

First of all, ur comp () fn is wrong:
It must be:

bool comp(node a,node b)
{

if(a.block<b.block)
    return true;  

else if (a.block>b.block) // u havent added this  

    return false;  

else
    return (a.right<b.right);

}

Doing this runs the 1st subtask. Now, u are applying MO’s for each query qhich is giving TLE. Preprocess all the query points, and apply MO’s only once.