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 |
为什么我跟AC程序对拍还是错的啊var ans,m,n,tot,i,j,ll,rr:longint; d,t,v,p,l,x:array[1..100] of longint; next,h,point,w:array[1..10000] of longint; bj:array[1..100] of boolean; function min(a,b:longint):longint; begin if a<b then exit(a) else exit(b); end; procedure link(a,b,i,p:longint); begin next[i]:=h[a]; h[a]:=i; point[i]:=b; w[i]:=p; end; procedure spfa(s:longint); var i,j,k,l,r:longint; use:array[1..100] of boolean; q:array[1..100] of longint; begin fillchar(d,sizeof(d),100); fillchar(use,sizeof(use),false); fillchar(q,sizeof(q),0); l:=0; r:=1; d[s]:=p[s]; use[s]:=true; q[r]:=s; repeat l:=(l+1) mod 100; i:=q[l]; j:=h[i]; while j<>0 do begin k:=point[j]; if (d[i]+w[j]<d[k])and(bj[k]) then begin d[k]:=d[i]+w[j]; if not use[k] then begin use[k]:=true; r:=(r+1) mod 100; q[r]:=k; end; end; j:=next[j]; end; use[i]:=true; until l=r; end; begin readln(m,n); for i:=1 to n do begin readln(p[i],l[i],x[i]); for j:=1 to x[i] do begin readln(t[j],v[j]); inc(tot); link(t[j],i,tot,min(p[i],v[j])); end; end; ans:=maxlongint; ll:=l[1]-m; rr:=l[1]; while ll<=l[1] do begin fillchar(bj,sizeof(bj),false); for j:=1 to n do if (l[j]>=ll)and(l[j]<=rr) then bj[j]:=true; for j:=1 to n do if bj[j] then begin spfa(j); if d[1]<ans then ans:=d[1]; end; inc(ll); inc(rr); end; writeln(ans); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator