早教吧 育儿知识 作业答案 考试题库 百科 知识分享

英语翻译Davidhatestowaitatstopsigns,yieldsignsandtrafficsignalswhiledriving.Tominimizethisaggravation,hehaspreparedmapsofthevariousregionsinwhichhefrequentlydrives,andmeasuredtheaveragedelay(inseconds)ateachof

题目详情
英语翻译
David hates to wait at stop signs,yield signs and traffic signals while driving.To minimize this aggravation,he has prepared maps of the various regions in which he frequently drives,and measured the average delay (in seconds) at each of the various intersections in these regions.He wants to find the routes between specified points in these regions which minimize his delay at intersections (regardless of the total distance he has to drive to avoid delays),and has enlisted your assistance in this effort.
Input
For each region,David provides you with a map.The map data first identifies some number of intersections,NI.The regions never include more than 10 intersections.The intersections in each region are numbered sequentially,starting with the number one (1).For each intersection,in turn,the input then specifies the number of streets leading away from the intersection,and for each such street,the number of the intersection to which the street leads,and the average delay,in seconds,that David encounters at that intersection.Following the data for the last intersection in a region there appear the numbers associated with the intersections where David wants to start and end his drive.The entire input consists of a sequence of maps,followed by the single integer zero (0).
Output
For each region,in order,print a single line of output which contains the region number (they,too,are sequentially numbered,starting with 1),a list of the intersection numbers David will encounter in the route with minimum average delay,and the average number of seconds he will be delayed while travelling this route.A suitable format is shown in the example below.
Notes
There will always be a unique route with the minimum average delay in each region.
A street from intersection I to intersection J is one-way.To represent a two-way street from I to J,the map must also include a route from intersection J to intersection I.
There will never be more than one route directly from intersection I to intersection J.
Example
Suppose David wants to travel from intersection 2 to intersection 4 in the region shown in the following map:
▼优质解答
答案和解析
大卫讨厌等待停止的迹象,产量标志和交通信号,而驾驶.为了尽量减少这种恶化,他已经准备地图,各地区,他经常驱动器和测量的平均延迟时间(以秒为单位)在各个不同的十字路口在这些地区.他希望找到指定的路线点之间在这些地区最少他毫不延迟地在十字路口(不论总距离,他开车,以免延误) ,并已物色到合适你协助这项工作.
输入
为每一个区域,大卫为您提供了地图.地图数据首先确定了一些一些路口,倪.该区域没有包括超过10个路口.该路口在每个区域的编号顺序,首先是排名第一( 1 ) .对于每一个十字路口,反过来,然后输入指定一些街道领导远离十字路口,并为每个这样的街,在一些十字路口,以街道领导,平均延迟,在几秒钟内,即在遇到大卫这相交.下面的数据最后交汇在一个地区的数字似乎与交叉口大卫希望的开始和结束他的驱动器.整个输入包括一个序列图,其次是单一的整数为零( 0 ) .
输出
为每一个区域,以便打印单一的输出含有该区域号码(他们也按顺序编号,从1 )的名单,相交数大卫会遇到的路线与最低平均延误,和平均多少秒,他将被推迟,而这条路线行驶.适当的格式显示在下面的例子.

总会有一个独特的途径与最低平均延误在每个区域.
街道从交叉口一相交J是单向的.代表一条双行道从I至J ,地图还必须包括航线相交J至十字路口一
人们将永远不会超过一个路线直接从交叉口一相交学者
例如
假设大卫希望从交叉口2至十字路口4在该区域显示在下面的地图: