GSS1- segment tree problem from SPOJ. Can't remove SIGSEGV, help needed.

The problem is GSS1 and my solution is very close to AC but I just can’t seem to find why my code gives SIGSEGV segmentation fault on G4G IDE. Please take a quick look at the code and let me know, it will be a big help!
Thanks a lot!

Indeed quite a few blunders in your code:

1.

int t = 1;
cin >> t;

I don’t think any explanation required here.

2.Don’t initialize result node values with LONG_MIN in query function as they will overflow if a -ve no. will be added to result.

AC Code

3 Likes

Thank you so much! It takes great courage to go through someone else’s lousy code and find the mistake, and people who do it are my type of heroes. The world needs more people like you, Divik. :slight_smile:

1 Like