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

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

Hello all

Can anyone tell me how to solve this problem?

Query 1 — Equate all elements in range l to r equal to x

Query 2 — Find sum of all the elements from range l to r.

Constraints : n  <  =  100000

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

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

This is classic segment tree with lazy propagation problem, just use google or etc...

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

Hi, you can learn a lot from here: Easy and efficient segment trees

Basically your query 1 is a interval modification using lazy propagation (calculating only the values you need when you need them) and the query 2 is a basic range query. Everything is explained in the link I provided. GL