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

Автор gs15120, история, 4 года назад, По-английски

Let array a1,...,an, ( 1<= n <= 10^6 )

3 kinds of quarries, m in total ( 1<= m <= 10^6 )

1 l r k: add k to al, ..., ar

2 l r k: change ai ( l<= i <=r ) in to max( ai , k )

3 l r: print max( al, ... ,ar )

I think it could be done it at mlogn by segment tree. How can I?

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

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

Isn't this $$$\mathcal{O}(mn)$$$ anyway, if someone decides to just spam 3 1 n over and over and over again.

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

    You would have to print only the largest value, am I wrong?

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится -8 Проголосовать: не нравится

      Ah, forgive me, I horribly misread. I thought it asked to print all the elements in the range, which is quite stupid of me tbh.

      Anyway, the comment of tfg should answer the question pretty well.

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

You're correct, you can do it better than quadratic. Read https://codeforces.com/blog/entry/57319, it's in there as task 2.