KING-SEN's blog

By KING-SEN, history, 8 years ago, In English

http://www.spoj.com/problems/HORRIBLE/ Hi everybody, I want to solve this problem with segment tree lazy propagation. I code it with segment tree lazy propagation but it gives me a wrong answer.I check it but I am unable to find any bug. Please anyone can help me to check my code and give me any solution for it.
code link: http://codepad.org/0LePV2tI

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +8 Vote: I do not like it

I guess this could be the problem

memset(ara, 0, n);
memset(lazy, 0, 3*n);
  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I replace the memset(ara, 0, sizeof (ara)); and memset(lazy, 0, sizeof(lazy)); But worng answer.

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

      Check your query function! It might overflow

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

Please recommend some good tutorials for segment tree and binary indexed tree?