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

Автор maulik12, 9 лет назад, По-английски

Hi Everyone, I have been practicing Segment trees and there's a very straightforward problem on SPOJ. Link:http://www.spoj.com/problems/CDC12_H/

I have used Lazy Propagation by I am getting WA. And I don't know why. Here's my code. Link: http://ideone.com/gAx34B

Its pretty much understandable. Please tell me as to where I am wrong . Thanks, Maulik

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

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

Lines 34-35 and 66-67 Replace

    lazy[2*index+1]+=1;
    lazy[2*index+2]+=1;

By:

    lazy[2*index+1]+=lazy[index];
    lazy[2*index+2]+=lazy[index];
»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I have read your code and changed it and it got AC! here is your code: http://ideone.com/emLhch