bzoj-3876-Spur plot-ahoi2014-Upper and lower bounds network flow

Source: Internet
Author: User

Describe

"Story Background"
Otaku Jyy very much like to play RPG games, such as Paladin, Xuan Jian and so on. But jyy like not fighting scenes, but similar to the drama of the general hatred of the story. These games are often
There are a lot of spur plots, and now jyy want to spend the least time watching all the spur plots.
"Problem description"
Jyy now play the RPG game, there are a total of n plot points, from 1 to n numbered, the first I plot points can be based on the different choices of jyy, and through the different feeder plot, go to Ki species different new plot points. Of course, if it is 0, it means that the I plot point is a game ending.
Jyy It takes some time to watch a spur plot. Jyy began at the 1th plot point, the beginning of the game. Obviously any plot point is from the number 1th plot point can reach. In addition, as the game progresses, the plot is irreversible. So the game is guaranteed to start from any plot point, can not return to this plot point. The "archive" and "read" functions of the game are corrupted due to the jyy overuse of the modifier.
So jyy to go back to the previous plot point, the only way is to quit the current game, and start a new game, that is, back to the 1th plot point. Jyy can exit the game at any time and start over again. Constantly start a new game repeatedly watching the plot has been seen is very painful, jyy hope to spend the least time, read all the different spur plot.

Analysis
    • Network flow with upper and lower bounds
    • In the title "The game guarantees from any plot point, can not return to this plot point" the condition guarantees this is a topology diagram namely DAG.
    • For the Edge X->y in the original image, the cost is costs, the edge goes at least once, and each time is the same. Then you can start with each point (INF, 0), X->y (INF, cost), y-> meeting point (1, 0). Then limit the x->y traffic to the lower limit.
    • With regard to the network flow problem with lower flow rate, a more intuitive way to understand this is if the x->y capacity is cap and the lower limit is low, then let Cap-low as the new capacity. But then the flow of x and Y is not conserved, the straightforward point is that the flow of x flow to Y is also X's ancestor flow to X, then directly after the low cut off the X's ancestors will not flow low to X. Then the flow is not conserved. Y loses part of the traffic, and X's traffic is surplus.
      The solution is to create an additional source and an additional sink, which will supply y of the low traffic and then pass the X traffic low through the additional bus. Balance the edge of the INF with the original source. Add additional sources and add-ons as new Yuanhui to run the minimum cost maximum flow.
Code

https://code.csdn.net/snippets/623430

bzoj-3876-Spur plot-ahoi2014-Upper and lower bounds network flow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.