2D Segment Tree with range multiplication, is it possible?

Правка en2, от bochet, 2015-07-01 17:53:35

Hi all,

This is my first blog in Codeforces. I met an optimisation problem in my work. The problem can be simplified as this:

we need to perform two operations on a matrix A:

  1. multiply a sub matrix (given xmin, xmax, ymin, ymax) of A by a constant c_i
  2. query the sum of a sub matrix of A

My first idea is to use 2D segment tree with range update because I have seen and solved problems like (1) 2D segment tree for rmq, (2) 1d segment tree with range multiplication. But after spending one day trying to combine 2d segment tree with range multiplication, I found it very difficult (or maybe impossible ?) to do that because the two nodes may intersect, for example in:

http://codeforces.net/predownloaded/72/63/7263f47bb299330d4dc4a4c3d2e81b848bd87920.png

will intersect at point (2, 3) and other points, and that makes everything so hard!

I can switch to quadtree to avoid such a problem, but then it means the single operation complexity would go from O(log(W)*log(H)) to O(W+H).

So can you help me with this problem?

Теги segment tree, range update, 2d trees

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский bochet 2015-07-01 17:55:50 6
en2 Английский bochet 2015-07-01 17:53:35 150
en1 Английский bochet 2015-07-01 17:49:51 1053 Initial revision (published)