Topic Link: Click to open the linkFor a tree without a direction:Start at any point, find the farthest point, set this as the starting point, and find the farthest point from the starting point as the destination.This road is the diameter.two times BFS;#include Sdut 3045-Graph theory of Mystery (diameter of tree)
Graph write tree Uva-10562
Approximate question:
Converts a multi-Cross Tree into a bracket expression.
Each node contains only "-", "|", and spaces.
Each non-leaf node always has a "|" character at the front and bottom, followed by a row of "-" characters, which exactly overwrites the top of all child nodes.
A single line "#" indicates the end mark of the data.
The topic describes that there are N cities, some of which can be built between highways, and the cost of building different highways is different.Now we want to know, at least how much it costs to repair the road can connect all the cities together, so that in any city, you can reach any other city. The input input contains multiple sets of data in the following format. The first line consists of two integers n m, representing the number of cities and the number of roads that can be built.(n 3
Title: http://acm.hdu.edu.cn/showproblem.php?pid=3072
Question: There are n individuals, there are M-Bar relationship U v C, which represents you can inform V to spend C, if they can connect with each other (can be indirectly through others), then spend 0, ask from the point of notice to everyone, minimum cost is how much.
Train of thought: people who can relate to each other cost 0, means that in the same strong connected component of the point cost of 0, then naturally think of the reduction
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.