[Template] dynamic DP

luogu portal .

Recently learned about the dynamic dp, the feeling did not imagine the difficulty.

Dynamic DP

The DP is so simple:

To the tree, each point to a weight, find what the maximum weight independent set.

This DP is dynamic:

To the tree, each point to a weight has changed everywhere, each time seeking to change what the maximum weight independent set.


Digression:

($ NOIP2018 $ defend the kingdom)

Gangster: $ dp $ dynamic board directly seconds.

Fairy: This is what Ah let me think ...... multiply? (Spot is then cut off)

In addition to big brother except gods besides Me: knock violence.

:( I misread the question of explosive eggs)


Several pre-knowledge:

(1) a heavy chain split

Select the most points subtree sons son when heavy tree section.

Several re-sectional properties:

1. The end must be leaves. (Tree sectional continuity)

2. a heavy chain is a contiguous segment split heavy chain sequence. (Tree sectional continuity)

3. root go through any point of the light chain does not exceed $ $ logN article. ( Weight sectional characteristics )

4.……

(2) matrix

Take the famous moment due to meet in conjunction with the law can be used to accelerate the recurrence / partition.

Bigwigs do not know ye want to come up with the following operations:

$$\begin{pmatrix}a00&a01\\a10&a11\end{pmatrix}+\begin{pmatrix}b00&b01\\b10&b11\end{pmatrix} $$

$$= \begin{pmatrix}max(a00+b00,a01+b10)&max(a00+b10,a01+b11)\\max(a10+b00,a11+b10)&max(a10+b01,a11+b11)$$

This thing actually is associative ......

Guess you like

Origin www.cnblogs.com/LiGuanlin1124/p/11101029.html