Solution to a problem scrawl

The brain is not awake at night (to be exact into the shi , always I wanted to change pants ???, what sb OCD )

 

 

Then write down the solution to a problem it is.

 

Any analog 20

If any two points only to ensure a simple communication paths, it means acyclic forest FIG.

Suppose a number of nodes communicating block is n, because it must be a tree, the number of sides is n-1.

Then we can conclude summarized: communicating the number of blocks = Points - the number of edges.

It is easy to think of a prefix and a two-dimensional, respectively maintenance and edges.

Is easy to solve, small inclusion and exclusion can be.

Bad side, then divided for the problem with this ill-defined, can be specified.

We require a side point of considering only the right and down.

In this way we can get any of the side of the matrix, the matrix for the right and the lower part of maintaining statistics and more rows and columns side even to consider.

 

 

Minimum spanning tree:

Analog 23 water

A water level from this point is the arrival point of the minimum of all boundaries (the maximum value of the path)

In other words, to find a path on the right side of the maximum path of least, find the minimum value.

We prove next:

X is disposed above demand, h is the water level at this point of the

Obviously, this point as long as there is a path to reach the border, it is not met

H greater than x assuming that, if we continue along this path, not satisfied, because x is the highest point of this road, there is no point can block the flow of water (this road) can already be through to the border.

      Since there is already a path does not satisfy the above, h can not be greater than x

Suppose h is smaller than x, which satisfy the path, the maximum weight on the other paths must be greater than equal to x, then the other path empathy satisfied. It is possible to increase h.

In summary h = x.

So consider how to find x.

In fact, this is a class issue.

For maximum minimum maximum minimum value, it is easy to think of the two points, two points with a dimension stuck, then this dimension as known conditions to solve another dimension, then adjusted by judging legitimacy half.

This problem is also monotonic, however, does not allow the complexity of each block half.

We need an overall solution method:

Min / max spanning tree .

For each block even edge, the edge weight value of the height of the larger of the two blocks, boundary max (height, 0), then run Krus, root boundary, the answer is that the maximum point to the right side of the root.

 The maximum value of the minimum spanning tree to ensure that each border point to the path as small as possible, and then find the maximum value can be.

 

模拟24 Star Way To Heaven

Solution one: a dichotomy, does not verify, to be exact real number is thought to give up. . .

Two points, the radius of the star and the width of the border, and then verify the absence of memory left to right passageway.

In fact verification is very simple. As long as Put another angle.

Interconnecting bad judgment, not China Unicom is still possible.

Disjoint-set, all intersect the circle into a set of upper and lower boundaries record, Japanese sentence boundary, exists or not and to see a set of upper and lower boundaries stuck m. Complexity of O (k ^ 2logm)

Solution two: selecting the maximum value of the minimum distance. Ibid minimum spanning tree!

Delineate the boundary with the minimum spanning tree, careful to break out, because the border can go back.

Well, this tree is actually most closely connected to the border, that all the worst case must go through from left to right.

The answer is the greatest right side of the tree / 2

 

Guess you like

Origin www.cnblogs.com/hzoi-yzh/p/11370469.html
Recommended