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

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

Recently, I've just encountered this problem:$$$\newline$$$ Given a tree with $$$n$$$ vertices and rooted at $$$1$$$. Each vertex has an initial value, and initially, all these values are $$$0$$$.$$$\newline$$$ There are $$$q$$$ queries of two types:$$$\newline$$$ - "1 u": Find the sum of values of vertices in the subtree rooted at u.$$$\newline$$$ - "2 u": Find the value at vertex u.$$$\newline$$$ - "3 u v x": Increase the values of vertices on the simple path from u to v by x.$$$\newline$$$ Answer the queries of type 1 and 2.$$$\newline$$$ Constraints:

$$$ 1 \leq n,q \leq 200000 $$$
$$$ 1 \leq u,v \leq n $$$
$$$ 0 \leq |x| \leq 1000000 $$$

Time Limit:

$$$ 0.5s $$$

Are there any tricks to handle these types of queries with Euler Tour? I've thought about this problem for several days and haven't come up with any idea how to do it yet because of the update path queries. And with this time limit, I think HLD can't pass :<

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

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

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

Recently I have encountered a problem that can use Line Tree to solve. But I haven't found any article or blog writes about this Data Structure (or maybe it just a technique). Can anybody provide me with a link to an article or blog about it. (Sorry for my poor English)

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

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