Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

打算练下spfa,弄得我2个Wa!还好0ms。(核心代码)

Posted by imbeta at 2010-07-14 17:50:33 on Problem 1125
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator