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

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

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:

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?

Полный текст и комментарии »

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