记录编号 |
13946 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[USACO Nov07] 奶牛跨栏 |
最终得分 |
100 |
用户昵称 |
ZhouZn1 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
1.194 s |
提交时间 |
2009-10-19 21:34:26 |
内存使用 |
0.46 MiB |
显示代码纯文本
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.