比赛 |
20121107 |
评测结果 |
AAWWW |
题目名称 |
最难的任务 |
最终得分 |
40 |
用户昵称 |
limitation |
运行时间 |
0.738 s |
代码语言 |
Pascal |
内存使用 |
0.51 MiB |
提交时间 |
2012-11-07 11:05:56 |
显示代码纯文本
program hardest;
var t,i,j,k,x,y,n,loop,m:longint;
a:array[1..300,1..300]of longint;
begin
assign(input,'hardest.in');
reset(input);
assign(output,'hardest.out');
rewrite(output);
read(t);
for loop:=1 to t do
begin
read(n,m);
for i:=1 to n do
for j:=1 to n do
a[i,j]:=100000;
for i:=1 to n do
a[i,i]:=0;
for i:=1 to m do
begin
read(x,y,a[x,y]);
a[y,x]:=a[x,y];
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if a[i,j]>a[i,k]+a[k,j] then a[i,j]:=a[i,k]+a[k,j];
if a[1,n]<>100000then write(a[1,n]) else write(-1);
end;
close(input);
close(output);
end.