22854_CowRelays

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

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

Pro.ID

22854

Title

Cow Relays

Title链接

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

AC

16

Submit

85

Ratio

18.82%

时间&空间限制

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

    Farmer John has formed a relay team for a race by choosing K (2 ≤ K ≤ 40) of his cows.  The race is run on FJ's farm which has N (4 ≤ N < 800) fields numbered 1..N and M (1 ≤ M ≤ 4000) unique bidirectional pathways that connect pairs of different fields.  You will be given the time it takes a cow to traverse each pathway.

    The first cow begins the race in field #1 and runs to the finish line in field #N. As soon as the first cow finishes, the next cow then starts from field #1 and runs to field #N and so on.  For this race, no two cows can follow precisely the same route (a route is a sequence of fields).

    Write a program which computes the minimum possible time required for FJ's relay team.  It is guaranteed that some minimum possible time exists.  Any cows can revisit a path in her trip to the other barn if that turns out to be required for a "best" solution.  As soon as a cow enters field #N, her relay leg is finished.

    输入

    * Line 1: One line with three integers: K, N, and M

    * Lines 2..M+1: Each line contains three integers describing a path: the starting field, the ending field, and the integer time to traverse the path (in the range 1..9500).

    输出

    Description

    Farmer John has formed a relay team for a race by choosing K (2 ≤ K ≤ 40) of his cows.  The race is run on FJ's farm which has N (4 ≤ N < 800) fields numbered 1..N and M (1 ≤ M ≤ 4000) unique bidirectional pathways that connect pairs of different fields.  You will be given the time it takes a cow to traverse each pathway.

    The first cow begins the race in field #1 and runs to the finish line in field #N. As soon as the first cow finishes, the next cow then starts from field #1 and runs to field #N and so on.  For this race, no two cows can follow precisely the same route (a route is a sequence of fields).

    Write a program which computes the minimum possible time required for FJ's relay team.  It is guaranteed that some minimum possible time exists.  Any cows can revisit a path in her trip to the other barn if that turns out to be required for a "best" solution.  As soon as a cow enters field #N, her relay leg is finished.

    Input

    * Line 1: One line with three integers: K, N, and M

    * Lines 2..M+1: Each line contains three integers describing a path: the starting field, the ending field, and the integer time to traverse the path (in the range 1..9500).

    Output

    One line with a single integer that is the minimum possible time to run a relay.

    Sample Input

    4 5 8
    1 2 1
    1 3 2
    1 4 2
    2 3 2
    2 5 3
    3 4 3
    3 5 4
    4 5 6

    Sample Output

    23

    Hint

    Namely: Cow 1: 1->2->5         4
            Cow 2: 1->3->5         6
            Cow 3: 1->2->1->2->5   6
            Cow 4: 1->2->3->5      7

    Source

    样例输入

    4 5 8
    1 2 1
    1 3 2
    1 4 2
    2 3 2
    2 5 3
    3 4 3
    3 5 4
    4 5 6

    样例输出

    23

    提示

    Namely: Cow 1: 1->2->5         4
            Cow 2: 1->3->5         6
            Cow 3: 1->2->1->2->5   6
            Cow 4: 1->2->3->5      7


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部