Network Flow topic Exercise Day2

Source: Internet
Author: User
Tags in degrees

04/17

Currently done:4 questions

As the current four is 1A feel very cool ...

BZOJ1412: [ZJOI2009] Wolf and sheep story "Wolves love the Sheep Ah love crazy, who let them really love A, wolf love sheep ah is not absurd, they say there is love is the direction ... "Orez heard this song, thought: Wolf and sheep so harmonious, why not try the sheep and wolves together?" Do what you say! Orez can be seen as a n*m matrix lattice, the edge of the matrix has been put on the fence. But Drake soon found that wolves are also wolves, they are always watering to the sheep, the song is just a moving legend. So Orez decided to add some fences in the Sheep Wolf Circle, or to keep the wolves separately. Through careful observation, Orez found that wolves and sheep have their own territory, if wolves and sheep can not stay in their own territory, then they will become very irritable, not conducive to their growth. Orez want to add the fence as short as possible. Of course, the fence must first be guaranteed not to change the wolf sheep's territory, and then the fence has to be built intact, that is, must be built on the boundaries of the unit lattice and can not only build part.

  

First of all, the test instructions of the problem is obviously to let us separate the wolves and the flock with the fewest number of fences.

The simplification, that is, with the fewest sides to cut off all wolves and sheep relations, so that is the smallest cut problem

Set up a source point to connect all the wolves, all the sheep to the meeting point each one side, the capacity of these edges are set to positive infinity, indicating that can not cut

For adjacent lattice to establish a capacity of 1 edge, the same group can not build a side, the sheep do not need to build the edge

And then you can run the maximum flow.

BZOJ2424: [HAOI2010] Order

A company estimates that the market in the first month of a product demand for a UI, known in the first month of the product's order unit price is DI, last month the unit product to pay the storage cost m, assuming that the first month of the stock is zero, the end of the second month of the inventory is zero, ask how to arrange the N-month subscription plan, To make the lowest cost? Orders at the beginning of each month, the product immediately after the purchase, into the library and supply the market, sold out in the current month does not have to pay the storage fee. Suppose the warehouse capacity is S.

It's almost exactly the same as the napkin plan. Two points to change

One is the cost of the point that is connected from the source point to the left is no longer 0, but the cost of the same day purchase

Because this problem can not be reused only in advance purchase

The second is that the warehouse has capacity (just started to think that the day of the use of goods also to calculate in inventory

This just needs to be split.

Minimum cost maximum flow

BZOJ1934: [Shoi2007]vote vote of goodwill

There are n children in the kindergarten who are going to vote to decide whether to sleep or not. To them, the problem is not very important, so they decided to carry forward the spirit of humility. Although everyone has their own ideas, but in order to take care of their friends of the idea, they can also vote and their own will be contrary to the vote. We define the number of conflicts in a poll as the total number of conflicts between good friends plus the number of people who have clashed with their own intentions. Our question is, how should each child vote in order to minimize the number of conflicts?

Establish a source point, connect all children willing to be 0, set up a meeting point connection will be 1 children, edge capacity of 1

Build a 1 edge between good friends

and the minimum number of collisions that we're asking for is the smallest cut.

Maximum flow can be run once

BZOJ3171: [Tjoi2013] Loop lattice

A looping lattice is a matrix in which all elements are arrows, pointing to adjacent four squares. Each element has a coordinate (row, column), where the upper-left corner of the element coordinates (0,0). Given a starting position (R,C)

, you can walk along an arrow line between the squares. That is, if (r,c) is a left arrow, then go to (r,c-1), if it is the right arrow then walk to (r,c+1), if it is the arrow then walk to (R-1,C), if it is down arrow then go (r+1,c), each row and each column is circular, that is, if you go out of the boundary, you will appear on the other
A perfect loop lattice is defined as: for any starting position, you can follow the arrows and eventually return to the starting position. If a loop does not fit perfectly, you can modify the arrows of any element to perfection. Given a loop lattice, you need to calculate the minimum number of elements that need to be modified to make it perfect.

  

The breakthrough in this problem lies in the nature of the perfect cyclic lattice: each lattice is 1 in degrees! (out of nature is 1)

And then it's the same as the Euler loop of the mixed graph.

Point at which the source point is connected to the <1, the capacity is 1-b[i], the point at which the sink points are connected to the >1, and the capacity is B[i]-1

For an arrow we will be able to turn it to its original point with a capacity of 1 for the side of the cost of 1

Minimum cost maximum flow solution

Network Flow topic Exercise Day2

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.