I was coding a build function for persistent segment tree using vectors and I am getting Runtime error.
I replaced vector with array and it passes.
The code is just a few lines.
Code using vector (State: gives Runtime error): http://ideone.com/2c5tec
Code using arrays (State: Okay): http://ideone.com/WxBwJJ
I spent hours trying to spot the bug in the code and I removed all the code which is irrelevant to the bug to make it more simple to debug.
What really makes it more weird is when i removed those: "v[p].l=" and "v[p].r" it runs okay, here is it: http://ideone.com/alzUxP (State: Okay)
I will appreciate it very much if anyone told me why it keeps giving RTE.
Thanks very much.