| ||||||||||
| 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 | |||||||||
哪位高手来帮小弟看看程序WA N 次了,对拍也拍不出来,或者给组数据吧。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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator