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 |
麻烦看下哪里错了~~3Qvar q,w,e,i,j,l,r,mid,n,m:longint; a,aa:array[0..1000,0..1000] of longint; f:array[0..1000]of boolean; dist:array[0..1000] of longint; function check(zhi:longint):boolean; var i,j,min,m:longint; begin for i:=1 to q do for j:=1 to q do begin if (aa[i,j]>zhi)and(aa[i,j]<>maxlongint) then a[i,j]:=1; if aa[i,j]=maxlongint then a[i,j]:=maxlongint; if aa[i,j]<=zhi then a[i,j]:=0; end; for i:=1 to q do dist[i]:=maxlongint; dist[1]:=0; fillchar(f,sizeof(f),false); for i:=1 to q-1 do begin min:=maxlongint; for j:=1 to q do if not(f[j])and(dist[j]<min) then begin min:=dist[j]; m:=j; end; f[m]:=true; for j:=1 to q do if not(f[j])and(a[m,j]<>maxlongint)and(dist[m]+a[m,j]<dist[j]) then dist[j]:=a[m,j]+dist[m]; end; if (zhi=0)and(dist[q]=maxlongint) then begin writeln(-1); halt; end; if dist[q]>e then exit(false) else exit(true); end; begin readln(q,w,e); for i:=1 to q do for j:=1 to q do aa[i,j]:=maxlongint; for i:=1 to w do begin read(n,m,aa[n,m]); aa[m,n]:=aa[n,m]; end; check(0); begin r:=maxlongint; while l<r do begin mid:=(l+r) div 2; if not check(mid) then l:=mid+1 else r:=mid; end; writeln(mid); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator