Luo Gu $ P1864 \ [NOI2009] $ binary search tree range $ dp $

Positive Solutions: range $ dp $

Report problem solving:

Portal $ QwQ $

First, according to the definition of a binary search tree found, the data is determined, the preorder tree has been changed, the only change is to change the weights by changing the depth of the junction.

Found weights herein is not meaningful, it is clear that the discretization off, then set $ f_ {i, j, w} $ represents sort the data and determining the $ [i, j] $ tree form this interval, all weight point are $ \ geq w $ of the minimum cost.

Consider enumerate $ k \ in [i, j] $ this piece is the root of the tree, transferred to two kinds.

The first is not changed $ val_k $, this case requires $ val_k \ geq w $, directly $ f_ {i, j, w} = f_ {i, k-1, w_k} + f_ {k + 1, j, w_k} + sum_ {i, j} $

The second is to change the $ val_k $ $ w $, there $ f_ {i, j, w} = f_ {i, k-1, w} + f_ {k + 1, j, w} + K + sum_ {i, j} $

Wailing seem to have forgotten to say is what a $ sum $ $ QwQ $, $ sum $ on $ [l, r] $ frequency of visits Aung $ QwQ $. Put the depth $ \ times $ simple access frequency change this the representation. still in very good understanding does not explain the $ QwQ $

$ Overrrrr $

Guess you like

Origin www.cnblogs.com/lqsukida/p/11622520.html