Hey everyone !! I m trying to solve HORRIBLE on spoj but I m getting WA again and again !! I m just not getting where am I getting wrong in my approach !! I have recoded it several times but I can't get the bug in my approach !! Here is the link to my code . Do have a look guys .
Thanks in advance .
P.S — I think code is clean and can be understood easily .
"You are given an array of N elements, which are initially all 0."
Just add
memset(lazy, 0, sizeof(lazy));
memset(tree, 0, sizeof(tree));
before working upon each test case to be sure that your segment tree is filled with zeroes in the beginning.
Code
thnx a lot !!! memset just slipped away my mind