Блог пользователя deepak_097

Автор deepak_097, история, 6 лет назад, По-английски

Problem Link- link

I am getting WA on this question can't figure it out where I am going wrong. I tested many cases in which my code is passing correctly :(. Please help me to get rid of this problem.

My solution- link

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Your update function.

Instead of if(s==idx)

Write if(s==e) and you should be good to go.

Just the statement if(s==idx) doesn't check if it's a leaf node as well, so it will modify every time a segment tree node starts with 's'.

Test case, in case you want to see a difference:

2 )) 2 1 0

Your code outputs NO, after changing to s==e, it outputs YES, answer is YES.