比赛 |
20091019练习题 |
评测结果 |
AAAAAAAAAA |
题目名称 |
奶牛跨栏 |
最终得分 |
100 |
用户昵称 |
chengyang |
运行时间 |
0.252 s |
代码语言 |
Pascal |
内存使用 |
0.51 MiB |
提交时间 |
2009-10-19 20:53:09 |
显示代码纯文本
program hurdles;
var
map:array[0..301,0..301]of longint;
i,j,k,m,n,t,a,b,c:longint;
begin
assign(input,'hurdles.in');
assign(output,'hurdles.out');
reset(input); rewrite(output);
readln(n,m,t);
for i:=0 to 301 do for j:=0 to 301 do map[i,j]:=-1;
for i:=1 to m do begin
readln(a,b,c);
map[a,b]:=c;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (map[i,k]>0)and(map[k,j]>0) then begin
a:=map[i,j]; b:=map[i,k]; c:=map[k,j];
if c>b then b:=c;
if (a>b)or(a=-1)then map[i,j]:=b;
end;
for i:=1 to t do begin
readln(a,b);
writeln(map[a,b]);
end;
close(input); close(output);
END.