比赛 |
20101110 |
评测结果 |
AAAAAAAAAA |
题目名称 |
奶牛派对 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-10 19:53:36 |
显示代码纯文本
- var
- n,m,p,x,y,i,j,max:longint;
- f,g:array[0..1000,0..1000]of longint;
- w,e:array[0..1000]of boolean;
- a,b:array[0..1001]of longint;
-
- procedure djs1;
- var
- i,j,s,h,d,ma:longint;
- begin
- w[p]:=true;
- s:=1;
- d:=p;
- while s<n do
- begin
- inc(s);
- h:=0;
- ma:=maxlongint;
- for i:=1 to n do
- if (not w[i]) then
- begin
- if a[d]+f[d,i]<a[i] then
- a[i]:=a[d]+f[d,i];
- if a[i]<ma then
- begin
- ma:=a[i];
- h:=i;
- end;
- end;
- w[h]:=true;
- d:=h;
- end;
- end;
-
- procedure djs2;
- var
- i,j,s,d,h,ma:longint;
- begin
- e[p]:=true;
- s:=1;
- d:=p;
- while s<n do
- begin
- inc(s);
- ma:=maxlongint;
- for i:=1 to n do
- if not e[i] then
- begin
- if b[d]+g[d,i]<b[i] then
- b[i]:=b[d]+g[d,i];
- if b[i]<ma then
- begin
- ma:=b[i];
- h:=i;
- end;
- end;
- e[h]:=true;
- d:=h;
- end;
- end;
-
- begin
- assign(input,'party.in'); reset(input);
- assign(output,'party.out'); rewrite(output);
- readln(n,m,p);
- for i:=1 to n do
- for j:=1 to n do
- begin
- f[i,j]:=10000000;
- g[i,j]:=10000000;
- end;
- for i:=1 to n do
- begin
- a[i]:=10000000;
- b[i]:=10000000;
- end;
- for i:=1 to m do
- begin
- readln(x,y,f[x,y]);
- if x=p then a[y]:=f[x,y];
- g[y,x]:=f[x,y];
- if y=p then b[x]:=g[y,x];
- end;
- djs1;
- djs2;
- max:=-maxlongint;
- for i:=1 to n do
- begin
- if (a[i]<10000000)and(b[i]<10000000)
- and(a[i]+b[i]>max) then
- max:=a[i]+b[i];
- end;
- writeln(max);
- close(input);
- close(output);
- end.