Switch record of bzoj version

Source: Internet
Author: User
1016: [jsoi2008] Minimum Spanning Tree count

Orz, I feel that the understanding of the minimum spanning tree is another step. PS: I have to say that the exploration of classical algorithms is endless. I can only learn and understand them through communication and increasing knowledge. It is really difficult to study on my own.

Let's analyze the Kruskal Algorithm in depth. The algorithm process is not much to mention. It directly proves that, assuming that the algorithm considers the K edge, the two ends of the edge are already in the same connected block (known as "Conflict "), to keep the edge of the tree after the connected block is added, We must delete an edge from the ring, and the connectivity has not changed, however, because the deleted edge weight is not greater than the current edge weight, the answer will not be better.

For this question, we need to see a property obtained by analyzing the process of finding the minimum spanning tree using the Kruskal algorithm:If K edge C with the same weight exists, the number of edge C added to the connection state is the same for different addition methods when considering the next edge weight, and the point connection state is the same. That is, the number of edges with the same edge weight in the Minimum Spanning Tree of a graph must be equal, and the connected state is the same after these edges are added.Proof: divide the same edge weight into an edge addition phase and set K edge C in the current phase. Assume that a conflict occurs when the T clause in K is taken into account. There are two situations: If the formed ring contains a previously added C edge, you can replace it so that the connectivity status does not change; if not, the current K-value edge cannot be added and the subsequent K-value edge cannot be added. Neither of the above two cases will increase the number of edge joins or change the connectivity status.

So it's pleasant.Kruskal brute force and query set to maintain connectivity + searchThe possible number of edge adding schemes in each stage can be multiplied. Note that there is no specific issue (because the above practice will output 1 when there is no solution ). The code is 23333 more online. Does the matrix-tree theorem seem useless ?? Shen (YDC in particular) explained 2333.


Switch record of bzoj version

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.