记录编号 | 21085 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [USACO Nov07] 奶牛跨栏 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.934 s | ||
提交时间 | 2010-11-03 09:21:10 | 内存使用 | 0.46 MiB | ||
program hurdles(input,output); var n,m,t,x,y,z:longint; a:array[1..300,1..300]of longint; i,j,k: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,t); for i:=1 to n do for j:=1 to n do if i<>j then a[i,j]:=-1; for i:=1 to m do begin readln(x,y,z); a[x,y]:=z; end; for k:=1 to n do for i:=1 to n do for j:=1 to n do if (a[i,k]<>-1)and(a[k,j]<>-1) then if (max(a[i,k],a[k,j])<a[i,j])or(a[i,j]=-1) then a[i,j]:=max(a[i,k],a[k,j]); for i:=1 to t do begin readln(x,y); writeln(a[x,y]); end; close(input); close(output); end.