Hdu3338 magic network stream (maximum Stream)

Source: Internet
Author: User

Kakuro Extension

The original riddle is a very interesting game. Each blank row or column is called a back. Each return corresponds to an integer sum, and sum is the sum of the returned values. You can only enter the nine numbers (1-9) in the blank box and cannot repeat each time. The black color is empty, and there is a number lattice. The lower-left corner indicates the column's sum, and the upper-right corner indicates the sum of rows. The following figure is displayed.

However, this question is not the original riddle. It is a little less rule than the original riddle, that is, the numbers displayed in each session can be repeated. Here is an N * m graph for you to fill in.

I have read this question, but I don't have many ideas. I can refer to the idea of solving the report, which can be done using network streams. The blank space is used as the node. For example, if the stream is inbound from the left, outbound from the top, inbound capacity is the row sum, outbound capacity is the column sum, and the remaining capacity remains unchanged. Find the maximum stream that is satisfied. Because there are upper and lower limits on traffic, you can reduce each number by 1, and the entered number range is 0-8, you can use a pure network flow. And then add it.

Graph creation:

There are four types of points:

1. Construct Source Vertex S, sink vertex t

2. There is a grid of rows and such nodes are set to

3. Blank Space, set to B

4. A grid with columns and columns is set to C.

You can create an edge:

1. <S, A> capacity and row and

2. <A, B> the capacity is 8

3. <B, c> the capacity is 8

4. <C, T> the capacity is column and

Of course, the reverse side capacity is set to 0.

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.