Report on solving the problem of the second warm-up competition in the December ACM round of Central South University

Source: Internet
Author: User

ProblemTerrain

The P in the question refers to the number of different paths covered by all the shortest paths between any two points. The maximum value of P is required.

A direct and violent idea is to use Floyd to process the shortest circuit between two I and j, and then enumerate I, j, each scan times the vertex to determine which vertex exists in all the shortest paths, that is, F [I] [k] + F [k] [J] = f [I] [J] is satisfied with K. Then, all edges on the shortest path must be the edges connected by vertices in K sets. Therefore, we need to add a pair of vertices x and y in K sets, determine whether the path between two points is on the shortest path, that is, whether f [I] [x] + G [x] [Y] + F [y] [J]

= F [I] [J] or F [I] [Y] + G [y] [x] + F [x] [J] = f [I] [j], and count.

It should be noted that because there may be multiple paths between two points, it is useless because it is obviously long, therefore, when reading the data, you can process and retain the shortest path between two points, and calculate the number by the way, which is convenient for subsequent statistics.

 

Problem BInfrastructure Construction

This question can be converted into a minimal cut solution.

Because profits can also be seen as all possible benefits minus construction costs, and the benefits of customers who have lost due to the absence of corresponding facilities, a graph can be created, on the left is the facilities to be built, on the right is the consumer group, and the center is connected from left to right to the directed edge with an infinite capacity, and a source point is constructed to connect with the facilities. The capacity is the construction cost, then, a collection point is constructed to connect the consumer group with the collection point separately. The capacity is the benefit of the consumption group.

Finally, find the minimum cut for the created graph.

 

Problem CBuy a swimming Ring

This question can be converted into covering as many intervals as possible with the least points.

Therefore, you can first sort the intervals in ascending order of the right endpoint, and sort the same right endpoint in descending order of the Left endpoint. Then, each vertex is placed on the right end point of the current first interval, until the left endpoint of a range is located on the right of the point, place the vertex again and update the count.

 

Problem dPrince frog crossing the river

The expected conclusion can be obtained through recursion. The result is (m + 1) * 2 ^ n.

First, the maximum number of frogs can pass and depends on the maximum number of frogs standing in the center of the river. The lotus leaf can only occupy one, we might as well fix the number of lotus leaves to observe the effect of stone column changes on the results.

We use F [m] [N] to show how many frogs can cross the river when there are m lotus leaves and N stone pillars. In fact, the stone column is similar to the shore. For example, if we analyze how many frogs can settle on the nth stone column, it is obviously equivalent to f [m] [n-1, because it can only achieve the goal with the help of other n-1 stone pillars and M lotus leaves.

So we got the conclusion that f [m] [N] = f [m] [n-1] (the frog on the nth stone column) + F [m] [n-1] (all the frogs that can pass across the other side in the rest ). Of course, since frogs on the nth column can reach the nth column, they can naturally reach the right bank, because the operations on frogs are reversible (convert the original A to D when you go back ).

Based on the above formula, we can naturally obtain f [m] [N] = f [m] [0] * 2 ^ N, f [m] [0] indicates that when there is no stone column, a frog can cross the Other Side. Naturally, m + 1 is used, and the final result is obtained.

 

Problem EStone game

To ensure the uniqueness of rows and columns, we can easily use a bipartite graph for processing. The left side is the row and the right side is the column. If there is a hole in the point, a corresponding edge is connected, in this way, we convert the problem into finding out whether the bipartite graph has a unique maximum match.

When seeking, we use greedy ideas. If the degree of a vertex is 1, the edge connected to the vertex must be obtained, delete the vertex and the edge connected to the vertex and continue to become greedy.

If some vertices are not deleted but their degrees are 0, then there is no solution. Second, if the degrees of some vertices are greater than 0 (or greater than 1), then there are multiple groups of solutions, it indicates that there is a unique solution.

 

Problem FHouse jumping game

This question can be solved using the method of the longest ascending subsequence of nlogn, except that the values smaller than the first vertex are ignored.

 

Problem gDifficulties in town management

We may set three sides to A, B, and C respectively. In fact, it is to determine which of the possible a conditions that meet a ^ 2 = C ^ 2-B ^ 2.

In fact, for integers C and B (C> B), we can infer that the value range of C ^ 2-B ^ 2 is a multiple of 4 except 4 and all odd numbers except 1, I will not prove this here. Leave it to everyone.

After that, it is easy to know that as long as a is not 1 or 2, it is OK.

 

Problem HQueuing

Basic linked list applications.

 

Problem IVIP discount card

Basic composite math. However, if we directly decode the operation, it will be out of the long int range. However, we find that the actual solution is smaller than the int representation range, in this way, we can use the Yang Hui triangle to solve the problem. First, we can prepare the Yang Hui triangle.

Of course, you can also use high precision.

 

Problem JFinancial Statistics

I wrote some questions ......

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.