比赛 |
20091019练习题 |
评测结果 |
AAAAAAAAAA |
题目名称 |
奶牛跨栏 |
最终得分 |
100 |
用户昵称 |
rottenwood |
运行时间 |
0.234 s |
代码语言 |
Pascal |
内存使用 |
0.81 MiB |
提交时间 |
2009-10-19 20:54:11 |
显示代码纯文本
program hurdles;
var
map:array[1..300,1..300] of longint;
mis:array[1..40000,1..2] of longint;
i,j,k,m,n,ans,ti,si,ei,hi:longint;
function max(x,y:longint):longint;
begin
if x>y then max:=x
else max:=y;
end;
begin
assign(input,'hurdles.in');reset(input);
assign(output,'hurdles.out');rewrite(output);
readln(n,m,ti);
for i:=1 to n do
for j:=1 to n do
map[i,j]:=-1;
for i:=1 to m do
begin
readln(si,ei,hi);
map[si,ei]:=hi;
end;
for i:=1 to ti do
readln(mis[i,1],mis[i,2]);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
begin
if (map[i,k]<>-1)and(map[k,j]<>-1) then
if (map[i,k]<map[i,j])and(map[k,j]<map[i,j])or(map[i,j]=-1) then map[i,j]:=max(map[i,k],map[k,j]);
end;
for i:=1 to ti do
writeln(map[mis[i,1],mis[i,2]]);
end.