
Dij
枫流仁武
这个作者很懒,什么都没留下…
展开
-
LeetCode 743 网络延迟问题
有N个网络节点,标记为1到N。给定一个列表times,表示信号经过有向边的传递时间。times[i] = (u, v, w),其中u是源节点,v是目标节点, w是一个信号从源节点传递到目标节点的时间。现在,我们从某个节点K发出一个信号。需要多久才能使所有节点都收到信号?如果不能使所有节点收到信号,返回-1。注意本题的w可以取到0,因此图初始化时节点值得大小不能为0,可以设为-1。采用Dij算法解决from typing import *import sys...原创 2020-10-14 10:36:17 · 218 阅读 · 0 评论 -
PAT 1030 Travel Plan
题目:A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest p...原创 2019-08-10 16:32:01 · 91 阅读 · 0 评论 -
PAT 1111 Online Map
题目要求:Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastes...原创 2019-08-10 17:38:59 · 104 阅读 · 0 评论 -
PAT 1072 Gas Station
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...原创 2019-08-27 09:35:50 · 77 阅读 · 0 评论 -
PAT 1087 All Roads Lead to Rome
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each ...原创 2019-08-26 18:55:41 · 116 阅读 · 0 评论 -
PAT 1003 Emergency
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l...原创 2019-08-31 09:44:38 · 70 阅读 · 0 评论