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

You are doing binary search for each query over each segment. That makes it O(NQlog(m)). Hence TLE :frowning:

1 Like

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

bool comp(node a,node b)

    return true;  

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

    return false;  

    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.