Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

res_and_ser's blog

By res_and_ser, history, 6 years ago, In English

Can anyone tell me how to implement this in C++.

A segment tree which finds range min query and on each update makes all the elements in a range equal to x.

Basically for two type of queries, it does this ;

1 l r means to find the min number from l to r

2 l r x means to make all the numbers in the array equal to x within range l to r.

Thank you in advance.

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

You need a lazy Segment Tree. You can learn about it here: e-maxx-eng. The last example in this tutorial is "Adding on segments, querying for maximum". It should be very easy to modify it to your needs.