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

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

Hello Codeforces

I want to represent (Tree) inside Segment Tree.

For Example: Given Tree, There are two queries:

1 — Change all the vertices value on the path from (u — v) by x.

2 — Calculate the sum for the vertices value on the path from (u — v) and print it.

I have no idea how to represent the tree inside the segment tree, any ideas?

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

»
9 лет назад, # |
Rev. 2   Проголосовать: нравится +18 Проголосовать: не нравится

Heavy Light Decomposition is what you're looking for:

Btw, did you create a new account to ask a question? If so, why?

»
9 лет назад, # |
Rev. 2   Проголосовать: нравится +2 Проголосовать: не нравится

You can do this using heavy-light decompostion + segment tree with lazy propagation on each of path.

Too late :(