比赛 |
20091019练习题 |
评测结果 |
AAAAAAAAAA |
题目名称 |
奶牛跨栏 |
最终得分 |
100 |
用户昵称 |
EnAsn |
运行时间 |
0.222 s |
代码语言 |
Pascal |
内存使用 |
0.51 MiB |
提交时间 |
2009-10-19 19:43:34 |
显示代码纯文本
program ex;
type
ss=array[1..300,1..300]of longint;
var
map:ss;
n,m,t:longint;
procedure floyed;
var
i,j,k:longint;
begin
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
if (map[k,j]<map[i,j])and(map[i,k]<map[i,j])or(map[i,j]=0) then
if map[i,k]>map[k,j] then map[i,j]:=map[i,k]
else map[i,j]:=map[k,j];
end;
procedure init;
var
s,e,h:longint;
i,j:longint;
begin
assign(input,'hurdles.in');
assign(output,'hurdles.out');
reset(input);
rewrite(output);
readln(n,m,t);
for i:=1 to m do
begin
readln(s,e,h);
map[s,e]:=h;
end;
floyed;
for i:=1 to t do
begin
readln(s,e);
if map[s,e]=0
then writeln('-1')
else writeln(map[s,e]);
end;
end;
begin
init;
close(input);
close(output);
end.