10263_RoutePlanning

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

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

Pro.ID

10263

Title

Route Planning

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Superior Island is a very picturesque island and only bicycles are allowed on the island. Therefore, there are many one-way bicycle roads connecting the different best photo-shooting spots on the island. To help the visitors plan their trip to the island, the tourism commission wants to designate r different bicycle routes that go through some of the best photo-shooting spots on the island. Given a map of all the bicycle roads on the island and a list of the best photo-shooting spots to be included on each of the three planned routes (non-listed spots must not be included in the route), please write a program to plan each of the r routes so that the distance on each route is minimal. Note that each best photo-shooting spot may only appear at most once on the route.

    输入

    There are two parts to the input. The first part of input gives the information of the bicycle roads on the island. The first line contains two integer n and r, n ≤ 100 and r ≤ 10, indicating that there are n best photo-shooting spots on the island and there are r routes to be planned. The next n lines (line 2 through line n+1) contains n × n integers (n lines with n integers on each line), where the jth integer on line i denotes the distance from best photo-shooting spot i-1 to best photo-shooting spot j; the distances are all between 0 and 10, where 0 indicates that there is no one-way road going from best photo-shooting spot i-1 to spot j.

    The second part of input has r lines, denoting the r sightseeing routes to be planed. Each line lists the best photo-shooting stops to be included in that route. The integers on each line denote the recommended photo-shooting stops on that particular sightseeing route. The first integer on the line is the starting point of the route and the last integer is the last stop on the route. However, the stops in between can be visited in any order.

    输出

    Description

    Superior Island is a very picturesque island and only bicycles are allowed on the island. Therefore, there are many one-way bicycle roads connecting the different best photo-shooting spots on the island. To help the visitors plan their trip to the island, the tourism commission wants to designate r different bicycle routes that go through some of the best photo-shooting spots on the island. Given a map of all the bicycle roads on the island and a list of the best photo-shooting spots to be included on each of the three planned routes (non-listed spots must not be included in the route), please write a program to plan each of the r routes so that the distance on each route is minimal. Note that each best photo-shooting spot may only appear at most once on the route.

    Input

    There are two parts to the input. The first part of input gives the information of the bicycle roads on the island. The first line contains two integer n and r, n ≤ 100 and r ≤ 10, indicating that there are n best photo-shooting spots on the island and there are r routes to be planned. The next n lines (line 2 through line n+1) contains n × n integers (n lines with n integers on each line), where the jth integer on line i denotes the distance from best photo-shooting spot i-1 to best photo-shooting spot j; the distances are all between 0 and 10, where 0 indicates that there is no one-way road going from best photo-shooting spot i-1 to spot j.

    The second part of input has r lines, denoting the r sightseeing routes to be planed. Each line lists the best photo-shooting stops to be included in that route. The integers on each line denote the recommended photo-shooting stops on that particular sightseeing route. The first integer on the line is the starting point of the route and the last integer is the last stop on the route. However, the stops in between can be visited in any order.

    Output

    Output r integers on r lines (one integer per line) indicating the distance of each of the r planned routes. If a route is not possible, output 0.

    Sample Input
    6 3
    0 1 2 0 1 1
    1 0 1 1 1 0
    0 2 0 1 3 0
    4 3 1 0 0 0
    0 0 1 1 0 0
    1 0 0 0 0 0
    1 3 5
    6 3 2 5
    6 1 2 3 4 5
    Sample Output
    5
    0
    7
    Source

    样例输入

    6 3
    0 1 2 0 1 1
    1 0 1 1 1 0
    0 2 0 1 3 0
    4 3 1 0 0 0
    0 0 1 1 0 0
    1 0 0 0 0 0
    1 3 5
    6 3 2 5
    6 1 2 3 4 5

    样例输出

    5
    0
    7

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部