Summary simulation of flow problems

Summary simulation of flow problems

Flow simulation problem are generally flows through the construction of a model of the observed properties of the stream data structures and efficient simulation of flow.

Codeforces 280 D. k-Maximum Subsequence Sum

Has a length \ (n-\) sequence, a single point of modification, maintenance, select up in this sequence \ (K \) disjoint sub-sequences and maximum weights, \ (n-\ ^ Leq 10. 5, k \ Leq 20 \) .

After the split point to build a cost flow model

\[ (S, S',k, 0) \\ (S', i, 1, 0) \\ (i+n,T,1,0) \\ (i,i+n,1,a_i) \\ (i + n ,i + 1,1,0) \]

We observed that each augmenting path is \ ((i, i + n , 1, a_i) \) maximum continuous sub-section side and then we can maintain maximum consecutive sub-segments and to find a augmenting path, reverse to the side only needs to be negated elected interval segment tree maintenance can be direct.

2019 Multi-University Training Contest Saltyfish

Has a size of \ (n-\) rooted tree, each point has \ (a_i \) apple, some point with a camera can be monitored from it within its subtree \ (\ leq d_i \) point is monitored Apple can not be selected, the camera needs to destroy \ (c_i \) cost required to maximize the total number of selected Apple \ (- \) for a total consideration. \ (n-\ Leq. 3 \ ^ 10. 5 Times \) .

The maximum weight classic closed subgraph Model
\ [(S, i, a_i
) \\ (j, T, c_j) \\ (i, j, \ inf) [j \ text {can observe} i] \] answer is the graph \ (\ sum a_i - \) minimum cut.

Observed that a traffic camera, must choose darker Apple's flow within its jurisdiction as far as possible, obviously the smaller the depth of Apple's more likely that the ancestors of the traffic camera augmented, so to maintain a flow of about depth information. This thing segment tree maintenance can merge, analyze the potential complexity is right.

NOI 2019 series

There are two lengths \ (n-\) sequence \ (A, B \) , needs to select each of the two sequences \ (K \) number, and a number satisfying a common position of the two selected sequences \ (\ GEQ L \) , \ (n-\ Leq. 6 10 ^ \) .

Cost flow model is not easy for me to think, the key is to build a pair of intermediate point \ (C, D \) to limit the selection is not public.
\ [(S, S ', k, 0) \\ (S', i, 1, A_i) \\ (i + n, T, 1, B_i) \\ (i, i + n, 1, 0) \\ (i, C, 1,
0) \\ (D, i + n, 1, 0) \\ (C, D, k - L, 0) \] construction cost flow out after no brain, violence pieces For all possible augmenting paths.

  1. \(S\rightarrow i\rightarrow i+n\rightarrow T\)
  2. \(S\rightarrow i\rightarrow C\rightarrow D\rightarrow i + n \rightarrow T\)

  3. \(S \rightarrow i \rightarrow i+n \rightarrow D \rightarrow j + n \rightarrow T\)
  4. \(S \rightarrow i \rightarrow C \rightarrow j \rightarrow j + n \rightarrow T\)

  5. \(S \rightarrow i \rightarrow i + n \rightarrow D \rightarrow C \rightarrow j \rightarrow j + n \rightarrow T\)

This time to consider how to maintain traffic, observed \ (S \ rightarrow i, i + n \ rightarrow T \) traffic actual meaning is \ (A_i / B_i \) if selected, \ (i \ rightarrow i + the n-\) is the actual meaning traffic is \ (A_i, B_i \) whether the simultaneously selected, \ (i \ rightarrow C, D \ rightarrow i \) and its reverse side if meaningful traffic is \ (A_i / B_i \) whether as an unordered point is selected, then we just need to control what augmented the total flow does not exceed \ (k \) , alone maintain it \ (C \ rightarrow D \) traffic can be.

So every time to find an augmenting path, just augmenting path in accordance with the corresponding five augmented way are taking practical significance to elect two points, while maintaining what \ (C \ rightarrow D \) traffic, attention fifth case this edge will flow back. Every elected two points need to use several stack maintenance, the details a little more.

In the actual simulation, I found that without the fifth augmented also can live, but does not prove, on the first write to you better.

Note that there is in fact the first \ (6 \) species augmented form, that is a common convection previously let the \ (C \ rightarrow D \) side, then put the augmented flow back flow, this thing is too much trouble simulation, but because the public as to whether the flow \ (C \ rightarrow D \) as the cost side, it is only necessary to control the public does not flow (C \ rightarrow D \) \ edge can be. Specific points of view constant \ (80-100 \) range.

UER 8 snowstorm and Take Away

There \ (n \) a mouse, \ (m \) hole, the hole has a flow \ (cap \) and costs \ (cost \) , the cost of the mice to a cave that \ (| x_i-y_j | \ ) , seeking all the mice went cave minimum cost.

This problem is a classic model of weighted bipartite graph matching, however, and the first few questions are not the same, to build a model for solving problems and no use. We can use a more obvious conclusions deduced, then put WC lecture algorithms.

Conclusion: matching side will not cross, because the cross is clearly larger than the cost of not cross.

We consider mouse from left to right and the hole, the hole encountered when mice and rats and appointed its matching hole on the left. For rats, a hole must be matched, if a match is like this does not exist, so that it matches a cost of \ (\ inf \) hole, then the mouse can go back, go back every time out is equivalent to revoke this match contributions and provide contributions for the next match. For this time of the cave, which is not qualified to go back, because once it go back, the mouse will lose the current match, after the match if their mouse to go back, after the rat hole to match is not possible, because then match it It will cross.

If you encounter a hole, match it to the left so that the mouse is the equivalent of the mouse left to go back until not good, pay attention to this point hole, and mice can all go back, go back above the mouse, the rat hole because the match left, it can let matched rat match back into the hole prior to the addition of state, and then match the mouse to the right of the hole. For a hole, it matches every mice were to go back on the cost is the same, it can be processed together with the rat heap maintenance and operation go back at any time to the left of the hole, the complexity of a \ (\ log \) .

ICPC World Finals 2018 to conquer the world

There \ (n-\) nodes of the tree, each node has a tree and a rat hole, a flow hole, the cost of the rat hole to a distance tree, minimizing the cost of all mice hole.

On a similar theme, from bottom to consider each node, each side will not be a two-way through, so when the match before the rat hole without having to go back when back flow. We deal with \ (lca \) for its matching contribution for each match is twice the depth of the depth of the hole, and mice and subtracting the current node, each time to remove it as \ (lca \) a pair of the most preferably augmented match, go back while adding operation. And can be used to maintain the heap.

Guess you like

Origin www.cnblogs.com/mangoyang/p/11563486.html