6371. [2019.9.28] NOIP2019 simulation exercises basis of graph theory

topic

Subject to the effect

Maintenance-free cutting a number of sides, plus support edge and border erase the graph.


Correct

(PS: This is what I long to play out before in the OJ solution to a problem, and now directly copy over)
solution to a problem is only one sentence, it is estimated that not many people can understand. Feeling lazy people do not want to write the topic and problem solution ......

Just one night finally understand the solution to a problem of practice ......

Because it has not AC (time in a hurry), so just here to sort out his thoughts, the way to look at the benefit of mankind.

First of all we know that segment tree partition is what the meaning of it?

Partition segment tree is an efficient use of alternative undo deletion routine. In this problem, all the plus side Erase operation into a plus side and undo. Can operate as a stack, it is the plus side of the stack, the revocation will only withdraw when back to front, is popped.

First off a wave, the processing time for each side of the interval to survive, then hang it online segment tree. Studied segment tree knows that it will cover the tree line of O (lg n) nodes.

The next segment tree traversal whole grain. After a node when it will be hung all the sides add to the mix. Because these side covers this node represents the time interval of these sides appear to completely cover the range of the node represents, which means there will be a whole range of these sides. Has been traversed down to the leaf node can count the answer. Backtracking when hanging backwards on the side of the node to withdraw off.

In this question among the LCT can be achieved, but O (n lg ^ 2 n), it will TLE.

The above is actually 49 minutes of practice ...... 100 practice solution to a problem of Laijiangjiang now.

When one edge of the tree line time interval is added, it will go through some of the nodes. Learned segment tree knows the number of nodes is O (lg n) th, and comprises node (point is actually passed to the root path point coverage and) it covers. We not only on the node side hang time interval covered, and then further with an array (or list) hang it passes the point.

After hanging on the mean time interval between interval and node represents intersect, that will have an impact on this side of the sub-tree leaf nodes part of the answer.

In the segment tree traversal down the current when the number of cutting edges. Figure we able to save each layer (in fact, the forest). Whenever to a node on the first layer copied to FIG. The endpoint nodes hanging on all sides to engage, and become a point set. We call this a useful set point. For point set out point, there is no need rationale behind it, it can shrink up to. How shrink point? Actually find useful set point, and then build a virtual tree.

Each side of the graph should write down how many sides of this cutting edge. When building a virtual tree condensing side, will cut the number of edges of the recording side of the road together.

Process can be used to build a virtual tree O (original point) of the method, the picture is one of FIG. Specifically, it is dfs again, sub-tree for each of them, whether there is a useful point of maintenance sub-tree which, if it is useful to remember point number. Back time, if there are two or more points of useful sub-tree, it must be added to the virtual tree. Otherwise, it does not need to be added.

After performing the above operation, only the entire useful points in FIG. Next, the node will cover all of the edges bang add to the mix. After adding a run again Tarjan, the ring shrunk to the point (in fact, do not fight Tarjan, specifically, if there is a throwback edge, directly here to the ancestors shrink up on it, after all, this is a undirected graph).

Of course, the plus side, the reduction point in the process, remember to maintain your answers (not suggested answers in the final calculation, because in the construction of imaginary tree when some useless point may be a leaf node, which is attached to that edge it is never to be reduced out if the final tally answer would be to ignore it; but in fact can remember what a useless point and still contribute a leaf node, plus at the last count).

Just think about your own time complexity will know, not repeat them here.

To implement this thing certainly is very troublesome. First to a pre-treatment survival of all the sides; followed by maintenance of a segment tree, each node maintains the edge covering which here, which edges through here; then traverse the segment tree, each layer must be kept a Figure (in fact, this figure is double the edge map), graph each edge to edge cutting edge record number represents, which recorded a useful point, maintaining a disjoint-set represent a useful point at which the double edge, there is a The answer; plus side and also reduce the operating point, or directly hit Tarjan disjoint-set to shrink.

Therefore, the time complexity is multiplied by a large constant ......

No code, there is no time to play ......
after %%% LYL, I spent two hours in time for the holidays and the bill, just a few weeks these problems the AC ......


to sum up

Segment tree partition is a common routine, become role is to undo the delete operation, the operation sequence becomes a form of stack into the stack.
When the operating cover segment tree node, the number of points after the \ (\ log \) level.
Therefore, the recording operation after a certain point, and then optimize the various operations, so the total number of sub-records is \ (n \ log n \) a.

Guess you like

Origin www.cnblogs.com/jz-597/p/11716129.html