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

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

According to animeshf, it is possible: his comment

But the implementation link he shared is expired so the implementation is gone! I'm confused one how to lazily propagate changes in the second dimension, more specifically how to store the lazy updates in a way so that both operations are logn^2 worst case.

Any ideas here?

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

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

Here is a way to support range sum query and range addition update. I don't know of a way to support range set update, however.

https://github.com/bqi343/USACO/blob/master/Storage/(2)%20Data%20Structures/(5)%202D%20BIT%20with%20Range%20Update.cpp

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

Auto comment: topic has been updated by brdy (previous revision, new revision, compare).

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

    Although the code is quite clean, would you please provide some explanation about it?

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

      Instead of lazily propagating down values he just adds them as he goes down. If a node is not completely within or out of the range he adds the lazy values from min(end,right) to max(start,left) to avoid over-adding. This won't work for max/min though, I'm not sure if there is another idea for those.