meintoo's blog

By meintoo, 9 years ago, In English

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 .

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

»
9 years ago, # |
Rev. 3   Vote: I like it +1 Vote: I do not like it

"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

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

    thnx a lot !!! memset just slipped away my mind