The brain cannot turn around

Source: Internet
Author: User

Family Crisis

Today, Wen Ge played this game for me. I used to play this game, forget how I used to pass it, and then I found that I was not able to get through it. It was also drunk. Then how can I get through .....

First of all, I did not have a thorough idea about the game, so I started to think about it directly:

1. It is all from one side of the bridge to the other side of the bridge, so I can think so. There were three back-and-forth steps, and the last one followed two people. Assume that the number of people in the past is a and B, then the return time is max (a, B) + min (a, B) = A + B; if you think this way, it is necessary to let more people go at the end.

Wen Ge said there was an error. The error was marked in red.

After thinking about it, I can actually use both sides of the bridge as two sets, that is, transfer all data from one set to another. I started to assume that the original starting point is s-set, and the destination is D-set. Now the problem with crossing the bridge is that two sets are interacting with data. Therefore, the incorrect formula should be max (a, B) + min (d ).

Since it is a data exchange between two sets, I think greedy, that is, each data transfer is the current minimum cost.

To simulate:

S-> d, 1, 3

D-> S, 1

S-> d, 1) 12, 8 2) 8, 6 3) 6, 1 .... the cost should be considered in the S-> D process, but because the elements in s reach D, in fact, there is no relationship between them. What is related is the combination problem, and the combination affects the cost.

D-> S, 3 Use D with the minimum cost in D-> S.

S-> d, 1, 3 in this step, is 1, 3; Low Cost

D-> S, 1

S-> d, 1, x end path

The above process is summarized as follows:

1. What acts as a messenger between the two combinations is that the smallest two in the element sorting.

2. When two messengers are scattered in two sets, they can be returned as a result of D-> S. Because the cost of creating S-> D () is completely less than that of min (a, B) If two other elements are selected ).

3. when two messengers are scattered in two sets, when S-> D, the largest group of elements can be passed over, so that the second largest element does not cost anything, it depends on the maximum element.

4. Create information when there is no messenger.

 

Miss thinking: First of all, I first thought that I had just come back and did not consider the people who were already on the opposite side. Secondly, I should not care about the flow process) focus on the two locations (SET ).

The brain cannot turn around

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.