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