记录编号 |
21523 |
评测结果 |
AAWAAAAATT |
题目名称 |
奶牛派对 |
最终得分 |
70 |
用户昵称 |
make |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
3.075 s |
提交时间 |
2010-11-11 09:57:58 |
内存使用 |
3.93 MiB |
显示代码纯文本
program party;
var
h:array [1..1000,1..1000] of longint;
n,m,x,max:longint;
f1,f2:text;
procedure init;
var i,j,k,u:longint;
begin
assign(f1,'party.in'); reset(f1);
assign(f2,'party.out'); rewrite(f2);
readln(f1,n,m,x);
for i:=1 to n do
for j:=1 to n do
h[i,j]:=maxlongint;
for u:=1 to m do begin
readln(f1,i,j,k);
if h[i,j]<>maxlongint then begin if k<h[i,j] then h[i,j]:=k; end
else h[i,j]:=k;
end;
close(f1);
max:=-1;
end;
procedure play;
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 (h[i,k]<>maxlongint)and(h[k,j]<>maxlongint) then
if (h[i,k]+h[k,j]<h[i,j]) then
h[i,j]:=h[i,k]+h[k,j];
end;
procedure search;
var i,j:longint;
begin
for i:=1 to n do
if h[i,x]+h[x,i]>max then max:=h[i,x]+h[x,i];
writeln(f2,max);
close(f2);
end;
begin
init;
play;
search;
end.