Obviously after the recent long challenge, I was trying to implement Mos Algo.
I used the following comparator,
struct query
{
ll l,r,idx;
query(ll _l , ll _r , ll _idx) : l(_l) , r(_r) , idx(_idx) {}
bool operator < (const query& myquery)
{
if( l/block_size != myquery.l/block_size)
return l/block_size < myquery.l/block_size;
else
return r <= myquery.r ;
}
};
This runs into a runtime error.
While this works fine
struct query
{
ll l,r,idx;
query(ll _l , ll _r , ll _idx) : l(_l) , r(_r) , idx(_idx) {}
bool operator < (const query& myquery)
{
return mp(l/block_size,r) < mp(myquery.l/block_size,myquery.r);
}
};
Why is this?