| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
打算练下spfa,弄得我2个Wa!还好0ms。(核心代码)for ii:=1 to n do
begin
for jj:=1 to n do dis[jj]:=maxx;
dis[ii]:=0;
fillchar(b,sizeof(b),false);
la:=1;a[1]:=ii; b[ii]:=true;
while la>0 do
begin
b[la]:=false;t:=a[la];dec(la);
for jj:=1 to g[t,0].y do
begin
if dis[g[t,jj].y]>dis[t]+g[t,jj].v then begin
dis[g[t,jj].y]:=dis[t]+g[t,jj].v;
if not b[g[t,jj].y] then begin
inc(la);a[la]:=g[t,jj].y;b[g[t,jj].y]:=true;
end;
end;
end;
end;
tot:=0;
for jj:=1 to n do if dis[jj]>tot then tot:=dis[jj];
if tot<max then
begin max:=tot;pmax:=ii;end;
end;
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator