22351_JoggingTrails

2022-5-16 18:21| 发布者: Hocassian| 查看: 20| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506346687799-Problem List-采集的数据-后羿采集器.html

Pro.ID

22351

Title

Jogging Trails

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22351

AC

3

Submit

3

Ratio

100.00%

时间&空间限制

  • Time Limit: 1200/400 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Gord is training for a marathon. Behind his house is a park with a large network of jogging trails connecting water stations. Gord wants to find the shortest jogging route that travels along every trail at least once.

    输入

    Input consists of several test cases. The first line of input for each case contains two positive integers: n <= 15, the number of water stations, and m < 1000, the number of trails. For each trail, there is one subsequent line of input containing three positive integers: the first two, between 1 and n, indicating the water stations at the end points of the trail; the third indicates the length of the trail, in cubits. There may be more than one trail between any two stations; each different trail is given only once in the input; each trail can be travelled in either direction. It is possible to reach any trail from any other trail by visiting a sequence of water stations connected by trails. Gord's route may start at any water station, and must end at the same station. A single line containing 0 follows the last test case.

    输出

    Description
    Gord is training for a marathon. Behind his house is a park with a large network of jogging trails connecting water stations. Gord wants to find the shortest jogging route that travels along every trail at least once.
    Input
    Input consists of several test cases. The first line of input for each case contains two positive integers: n <= 15, the number of water stations, and m < 1000, the number of trails. For each trail, there is one subsequent line of input containing three positive integers: the first two, between 1 and n, indicating the water stations at the end points of the trail; the third indicates the length of the trail, in cubits. There may be more than one trail between any two stations; each different trail is given only once in the input; each trail can be travelled in either direction. It is possible to reach any trail from any other trail by visiting a sequence of water stations connected by trails. Gord's route may start at any water station, and must end at the same station. A single line containing 0 follows the last test case.
    Output
    For each case, there should be one line of output giving the length of Gord's jogging route.
    Sample Input
    4 5
    1 2 3
    2 3 4
    3 4 5
    1 4 10
    1 3 12
    0
    Sample Output
    41
    Source

    样例输入

    4 5
    1 2 3
    2 3 4
    3 4 5
    1 4 10
    1 3 12
    0

    样例输出

    41

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部