10060_FarmTour

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

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

Pro.ID

10060

Title

Farm Tour

Title链接

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

AC

14

Submit

33

Ratio

42.42%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 ≤ N ≤ 1000) fields numbered 1..N, the first of which contains his house and the N-th of which contains the big barn. A total M (1 ≤ M ≤ 10000) paths that connect the fields in various ways. Each path connects two different fields and has a nonzero length smaller than 35,000.

    To show off his farm in the best way, he walks a tour that starts at his house, potentially travels through some fields, and ends at the barn. Later, he returns (potentially through some fields) back to his house again.

    He wants his tour to be as short as possible, however he doesn't want to walk on any given path more than once. Calculate the shortest tour possible. FJ is sure that some tour exists for any given farm.

    输入

    * Line 1:   Two space-separated integers: N and M.

    * Lines 2..M+1:   Three space-separated integers that define a path: The starting field, the end field, and the path's length.

    输出

    Description

    When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 ≤ N ≤ 1000) fields numbered 1..N, the first of which contains his house and the N-th of which contains the big barn. A total M (1 ≤ M ≤ 10000) paths that connect the fields in various ways. Each path connects two different fields and has a nonzero length smaller than 35,000.

    To show off his farm in the best way, he walks a tour that starts at his house, potentially travels through some fields, and ends at the barn. Later, he returns (potentially through some fields) back to his house again.

    He wants his tour to be as short as possible, however he doesn't want to walk on any given path more than once. Calculate the shortest tour possible. FJ is sure that some tour exists for any given farm.

    Input

    * Line 1:   Two space-separated integers: N and M.

    * Lines 2..M+1:   Three space-separated integers that define a path: The starting field, the end field, and the path's length.

    Output

    A single line containing the length of the shortest tour.

    Sample Input

    4 5
    1 2 1
    2 3 1
    3 4 1
    1 3 2
    2 4 2

    Sample Output

    6

    Source

    样例输入

    4 5
    1 2 1
    2 3 1
    3 4 1
    1 3 2
    2 4 2

    样例输出

    6

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部