8840553
Could anyone please point out my error in this one? I'm getting a runtime error whenever I call the following assertion in my lca() function
int x=firstOccurance[u];
int y=firstOccurance[v];
assert(x>=0 && x<m);
assert(y>=0 && y<m);
which is weird since I specifically ensure that this is not possible by running the following in main() after generating firstOccurance[]
for(int i=1;i<=n;++i)
{
assert(firstOccurance[i]>=0);
assert(firstOccurance[i]<m);
}
and this part happens to pass the assertion tests.
I have tried many random samples with n=100000 on my system, but could not replicate this error.
Thanks
Update: Corrected thanks to catlak_profesor_mfb
Since n was 100000,I had taken a size of 500000 for my segment tree which seemed to be sufficient. Unfortunately since the segment tree was on my order[] array, which has a size of 2*n-1, 500000 wasn't sufficient after all.
Full text and comments »