You are doing binary search for each query over each segment. That makes it O(NQlog(m)). Hence TLE
1 Like
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.