iamscrew's blog

By iamscrew, 7 years ago, In English

Runtime error on spoj

I have tried solving this problem LITE on spoj using segment tree with lazy propagation. The answer is coming fine in all the cases, but still i am getting runtime error on it. A similar problem occured when i tried to solve HORRIBLE on spoj. I modified the array size but it doesn't worked out. Can anybody please please figure it out? Thanks in advance. Here's my code.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

increase the array size to 1000000

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    @gauravbansal2000 thanks for replying. But i dont realise why the array size should be 1000000?

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Somewhere while doing 2*index+1 or 2*index+2 you might be accessing index greater than 200005. I tried to find the bug but i couldn't.Actually the size 200005 is enough for this problem.(i verified this by using 200005 in my solution to this problem,here is my code ).And you should indent your code it becomes hard to debug unindented code.