2017 "Wisdom Information Cup" Chinese undergraduate Program Design Competition National Invitational Contest (Hunan) and the nineth session of Xiangtan College Students Program Competition H.highway (diameter of the tree)

Source: Internet
Author: User


Highway
accepted:122 submit:393
Time limit:4000 MS Memory limit:65536 KB

Highway

In Icpccamp there were n towns conveniently numbered with 1,2,..., N connected with (n−1) roads. The I-th road connecting towns AI and bi has length ci. It is guaranteed the any two cities to the other using only roads.

Bobo would like "build" (n−1) highways so and any two towns reach each using only highways. Building a highway between towns X and y costs himδ (x,y) Cents, whereδ (x,y) is the length of the shortest path between t owns X and y using roads.

As Bobo is rich, he would the most expensive way to build the n−1. Input

The input contains zero or more test cases and are terminated by End-of-file. For each test case:

The contains an integer n. The i-th of the following (n−1) lines contains three integers AI

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.