Decision monotonic optimization study notes DP

use

When nonsense, of course, meet the equation DP to optimize certain properties complexity ......

definition

For \ (J \) to greater than \ (J \) a \ (I \) transfer, can be expressed as about \ (I \) function \ (F_j (I) \) , i.e. \ (dp_i = \ max / \ min \ {F_j (I) \} \) .

If taken \ (\ max \) , and in a place \ (f_j (i) \) from below ran \ (f_k (i) \) above (if added \ (f_j (i) \) when this function in already \ (f_k (i) \) above is not so), it is called \ (J \) replaces \ (K \) . Take \ (\ min \) Similarly.

If the decision monotonicity met, must be met: for any \ (I, J \ in [. 1, n-] \) , \ (F_j (X) \) and \ (f_i (x) \) no or only one intersection intersection, that is, \ (i \) and \ (j \) replaced at most once.

Narrow Decision monotony refers to \ (i <j \) and their decision points \ (P_i, p_j \) , there \ (P_i <p_j \) . That is, for \ (J <k \) , you can only have \ (k \) to replace \ (J \) .

Generalized decision means that as long as the monotony of a relationship problem to replace only (only replace a small big or small to replace large), it can be done.

Obviously, the monotony of a narrow decision-making is also encompassed within the broad decision-making monotonic.

Obviously, narrow and broad is my own series out.

Narrow Decision monotonic

Minute Osamu

Easy to understand for \ (dp_i = \ max / \ min \ {g_j + w_ {i, j} \} \) that the \ (dp_j \) independent recursive formula.

Consider a similar overall approach bipartite: Let \ (solve (l, r, L, R) \) represents a known \ ([l, r] \ ) entirely of \ ([L, R] \ ) transferred from, obtaining \ (DP [L, R & lt] \) .

Each set \ (MID = (L + R & lt) / 2 \) , then the sweep violent \ ([L, R & lt] \) , found \ (MID \) decision point \ (P \) , then partition \ ( Solve (L,. 1-MID, L, P) \) , \ (Solve (MID +. 1, R & lt, P, R & lt) \) .

Complexity: do \ (\ log n \) layers, each \ (\ sum (r-l + RL) \) are \ (O (n) \) , so the overall complexity \ (n-\ the n-log \) .

Pros: \ (w_ {i, j} \) is not \ (O (1) \) or \ (O (\ log n) \) calculating violent manner sweep might do it.

Disadvantages: Transfer of order, it must be recursive (f_j \) \ unrelated.

Note: If you do when it comes to sweep the \ ([R, L] \) , then the complexity of the analysis will hang!

Monotonous queue

Suitable \ (dp_i = \ max / \ min \ {dp_j + w_ {i, j} \} \) recursive formula requires \ (w_ {i, j} \) can be quickly determined.

Monotonic narrow decision quite early to ensure that after the decision point is replaced can be ignored, so you can maintain a queue, the first team is currently the best decision point, the tail is back to join, as well as the potential to replace the previous decisions point. (Denoted \ (q [l] \) is the head of the queue, \ (Q [R & lt] \) of the tail)

Considered at a time \ (q [l] \) and \ (Q [. 1 + L] \) , if the \ (q [l] \) is not so good, then put it flicked.

Join the current point of time, they engage in a number of things.

If that everything is added directly, then there will be such an embarrassing situation: \ (q [l] \) is better than \ (q [L + 1] \) , but \ (q [l] \) worse than \ (q [L + 2] \) .

How to avoid it? Using the above \ (f_j (x) \) function Shuxingjiege idea was added at this point if \ (I \) after \ (q [r] \) potential gone, i.e. \ (I \) substituted \ ( q [r-1] \) than \ (q [r] \) substituted \ (q [r-1] \) faster, then put \ (q [r] \) flicked. Thus, the above \ (q [l + 1] \) would not appear in the queue inside.

As for where the judge will replace, it would be half that position up.

Complexity: Obviously \ (O (the n-\ the n-log) \) .

Advantages: the transfer order.

Disadvantages: Requirements \ (w_ {i, j} \) can be quickly determined.

Generalized Decision monotonic

Big replace small time already mentioned above, will not repeat them.

Monotonous stack

It is small to replace large, such as \ (f_2 (i) \) has been unknown, and \ (f_4 (i) \) has been dominant, suddenly \ (i = 10 \) when two 4 replaced.

This time, it can no longer monotonous queue, but to use a monotonous stack. When the top of the stack is not superior to the following function when popped. If the current function when pressed \ (st [top-1] \) substituted \ (I \) than \ (st [top] \) is also popped quickly.

In fact, essentially monotonically queue and little difference, but also to two points, but also requires \ (w_ {i, j} \) can be determined quickly, but also the complexity of the \ (O (n-\ log n-) \) .

However, small to replace large that case only this kind of practice, so there is no advantages and disadvantages of a say.

Judgment decisions monotonic

We talk so much practice, but also did not say how to determine this nature.

This should normally be the first to write DP equation, various optimization methods will not try it again, then try to prove rigorous or sensual.

If it does not permit, it may be possible to play table guess conclusion. Guessed well and good, but if the random data over, and in fact the conclusion is false, and that ......

Then you have to pray that the person with the problem of random data.

In general I tend to guess the conclusion random data.

Guess you like

Origin www.cnblogs.com/p-b-p-b/p/11098973.html