(ssl1636)城市交通
2017-03-01 16:32
239 查看
城市交通
Time Limit:1000MS Memory Limit:65536K
Total Submit:101 Accepted:91
Description
有n个城市,编号1~n,有些城市之间有路相连,有些则没有,有路则当然有一个距离。现在规定只能从编号小的城市到编号大的城市,问你从编号为1的城市到编号为n的城市之间的最短距离是多少?
Input
先输入一个n,表示城市数,n小于100。
下面的n行是一个n*n的邻接矩阵map[i,j],其中map[i,j]=0表示城市i和城市j之间没有路相连,否则为两者之间的距离。
Output
输出格式:一个数,表示最少要多少时间。
输入数据保证可以从城市1飞到城市n。
Sample Input
Sample Output
Source
elba
Time Limit:1000MS Memory Limit:65536K
Total Submit:101 Accepted:91
Description
有n个城市,编号1~n,有些城市之间有路相连,有些则没有,有路则当然有一个距离。现在规定只能从编号小的城市到编号大的城市,问你从编号为1的城市到编号为n的城市之间的最短距离是多少?
Input
先输入一个n,表示城市数,n小于100。
下面的n行是一个n*n的邻接矩阵map[i,j],其中map[i,j]=0表示城市i和城市j之间没有路相连,否则为两者之间的距离。
Output
输出格式:一个数,表示最少要多少时间。
输入数据保证可以从城市1飞到城市n。
Sample Input
11 0 5 3 0 0 0 0 0 0 0 0 5 0 0 1 6 3 0 0 0 0 0 3 0 0 0 8 0 4 0 0 0 0 0 1 0 0 0 0 0 5 6 0 0 0 6 8 0 0 0 0 5 0 0 0 0 3 0 0 0 0 0 0 0 8 0 0 0 4 0 0 0 0 0 0 3 0 0 0 0 5 5 0 0 0 0 0 3 0 0 0 6 0 0 0 0 0 0 4 0 0 0 0 0 8 3 0 0 0 3 0 0 0 0 0 0 0 3 4 3 0
Sample Output
13
Source
elba
var f:array[1..100]of longint; a:array[1..100,1..100]of longint; i,j,n,min:longint; begin read(n); for i:=1 to n do for j:=1 to n do read(a[i,j]); for i:=2 to n do//选排 begin min:=10000; for j:=1 to i-1 do if a[j,i]<>0 then//如果他这条路可以走(飞) if f[j]+a[j,i]<=min then min:=f[j]+a[j,i];//打擂台 f[i]:=min;//装的是去这个城市到起点最短的路程 end; write(f ); end.
相关文章推荐
- 城市交通_ssl1636_floyd
- 城市交通-SSL 1636
- JudgeOnline 1636 城市交通!!!
- 大数据项目之智慧城市之智能交通系统框架设计
- 城市轨道交通信号与通信系统
- 全国主要城市交通卡芯片一览
- 城市大脑将成治市参谋,不只是用来解决交通问题
- 城市轨道交通之线路设计(一)
- 一卡通在城市轨道交通收费应用
- 城市交通
- 大连公交客运集团金马快轨运营分公司出台《城市轨道交通三号线行车事故处理规则》
- jzoj1749. 城市交通
- 《城市轨道交通——产业关联理论与应用》读书笔记
- 城市问题【SSL 1761】
- 全国主要城市交通卡芯片一览
- 智慧交通指挥决策平台,让“城市大脑”尽收眼底
- jzoj 1749 城市交通
- RFID电子标签改变了城市的交通拥堵
- 人工智能+概念高架路,能否缓解城市交通拥堵问题?
- (ssl 1761)城市问题