|
|||||||
АвтоАвтоматизацияАрхитектураАстрономияАудитБиологияБухгалтерияВоенное делоГенетикаГеографияГеологияГосударствоДомДругоеЖурналистика и СМИИзобретательствоИностранные языкиИнформатикаИскусствоИсторияКомпьютерыКулинарияКультураЛексикологияЛитератураЛогикаМаркетингМатематикаМашиностроениеМедицинаМенеджментМеталлы и СваркаМеханикаМузыкаНаселениеОбразованиеОхрана безопасности жизниОхрана ТрудаПедагогикаПолитикаПравоПриборостроениеПрограммированиеПроизводствоПромышленностьПсихологияРадиоРегилияСвязьСоциологияСпортСтандартизацияСтроительствоТехнологииТорговляТуризмФизикаФизиологияФилософияФинансыХимияХозяйствоЦеннообразованиеЧерчениеЭкологияЭконометрикаЭкономикаЭлектроникаЮриспунденкция |
Ограничение по памяти 64 М байт
A terrorist hides in an underground sewage system. Any two pipes have at most one common node that is also an endpoint for both of them. The terrorist hides in one such node and has placed clock-activated bombs at several other nodes. The passage into and through a node becomes impossible after the explosion. James Bond wants to capture this terrorist and has at his disposal a complete map of the sewage system that also highlights the position of the terrorist, the placement of the bombs, and their timings. At time 0 Bond starts from one of the nodes and must reach the terrorist in the shortest possible time. All pipes are bi-directional, at least for Bond. He can travel both ways with the same speed. Bond dies if an explosion catches him in one of the trapped node, but otherwise he is unscathed and can pursue his search (even if he is just one second away from the blast). Determine the minimum time that Bond needs to capture the terrorist, if this is possible. Input Line 1: Four positive integers N, M, S, T. N is the number of nodes and nodes are numbered 1, 2,... N. M is the number of pipes. There are at most one pipe between each pair of nodes. S is Bond's starting node, and T is the node where the terrorist hides (1 ≤ S, T ≤ N ≤ 100, 1 ≤ M ≤ N 2). Next N Lines: Each line contais 0 if the corresponding node is not trapped. Otherwise it contains a positive integer X giving the time when the bomb will detonate (1 ≤ X ≤ 1000). Next M Lines: Each line contains two node numbers representing the pipe's end nodes, and a positive integer giving the travel time Y between its end nodes (1 ≤ Y ≤ 1000). Output Print the minimum time that Bond needs to capture the terrorist, if this is possible (thus print 0 if Bond starts at the terrorist node). Otherwise print -1. Sample input and output
Задача 10. «Пиццерия» (алгоритм Флойда-Уоршолла) Входной файл pizzeria.in Выходной файл pizzeria.out Ограничение по времени 1 секунда на тест Ограничение по памяти 64 М байт The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait for 1 or more (up to 10) orders to be processed before he starts any deliveries. Needless to say, he would like to take the shortest route in delivering these goodies and returning to the pizzeria, even if it means passing the same location(s) or the pizzeria more than once on the way. He has commissioned you to write a program to help him. Input The first line will contain a single integer n indicating the number of orders to deliver, where 1 ≤ n ≤ 10. After this will be n + 1 lines each containing n + 1 integers indicating the times to travel between the pizzeria (numbered 0) and the n locations (numbers 1 to n). The j th value on the i th line indicates the time to go directly from location i to location j without visiting any other locations along the way (all values ≤ 1000). Note that there may be quicker ways to go from i to j via other locations, due to different speed limits, traffic lights, etc. Also, the time values may not be symmetric, i.e., the time to go directly from location i to j may not be the same as the time to go directly from location j to i. Output You should output a single number indicating the minimum time to deliver all of the pizzas and return to the pizzeria. Поиск по сайту: |
Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Студалл.Орг (0.003 сек.) |