比赛 |
20091019练习题 |
评测结果 |
AAAAAAAAAA |
题目名称 |
奶牛跨栏 |
最终得分 |
100 |
用户昵称 |
王瑞祥K |
运行时间 |
0.299 s |
代码语言 |
Pascal |
内存使用 |
0.51 MiB |
提交时间 |
2009-10-19 20:21:49 |
显示代码纯文本
program hurdles(input,output);
var
map:array[1..300,1..300]of longint;
n,m,t,i,j,k,x,y:longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a) else exit(b);
end;
begin
assign(input,'hurdles.in');assign(output,'hurdles.out');
reset(input);rewrite(output);
readln(n,m,t);
fillchar(map,sizeof(map),0);
for i:=1 to m do readln(x,y,map[x,y]);
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)and((max(map[i,k],map[k,j])<map[i,j])
or (map[i,j]=0))then map[i,j]:=max(map[i,k],map[k,j]);
for i:=1 to t do begin
readln(x,y);
if map[x,y]=0 then writeln(-1) else writeln(map[x,y]);
end;
close(input);close(output);
end.