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

哪位高手来帮小弟看看程序WA N 次了,对拍也拍不出来,或者给组数据吧。

Posted by 597100700 at 2010-12-29 15:13:50 on Problem 2394
var sum,a,b,c,d,e,f,m,n,k,t:longint;
 ss,dis:array[0..100000]of longint;
 path:array[0..1000,0..1000]of longint;
 q:array[0..1000000]of longint;
 flag:array[0..1000000]of boolean;
function jly(u,v:longint):boolean;
begin
 if path[u,v]+dis[u]<dis[v] then
  begin
  dis[v]:=path[u,v]+dis[u];
  exit(true);
  end;
  exit(false);
end;
procedure spfa(s:longint);
var v,l,r:longint;
begin
 l:=0;
 r:=0;
 inc(l);
 q[l]:=s;
 flag[s]:=true;
 while l<>r do
  begin
  r:=r mod m+1;
  v:=q[r];
  flag[v]:=false;
  for a:=1 to m do
   if jly(v,a) then
    if not flag[a] then
     begin
     l:=l mod m+1;
     q[l]:=a;
     flag[a]:=true;
     end;
  end;
end;
 begin
 assign(input,'x.in');reset(input);
 assign(output,'x.out');rewrite(output);
  fillchar(path,sizeof(path),127);
  fillchar(dis,sizeof(dis),127);
  fillchar(flag,sizeof(flag),false);
  fillchar(q,sizeof(q),0);
  readln(m,n,k,t);
  for a:=1 to n do
   begin
    readln(d,e,f);
    if f<path[d,e] then
     begin
     path[d,e]:=f;
     path[e,d]:=f;
     end;
   end;
   for a:=1 to k do
    readln(ss[a]);
   dis[1]:=0;
   spfa(1);
   sum:=0;
   for a:=1 to k do
    if dis[ss[a]]<=t then inc(sum);
    writeln(sum);
    for a:=1 to k do
     if dis[ss[a]]<=t then writeln(a);
  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