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 |
Re:我去,floyd竟然0ms,更诡异的是我数组开10*10竟然AC了!In Reply To:我去,floyd竟然0ms,更诡异的是我数组开10*10竟然AC了! Posted by:huangzhilv at 2011-06-06 15:30:41 > 以下是诡异代码 > 忘记改数组大小竟然AC了!而且是0ms > 改了100*100就32ms了…… > > program poj1125; > const > maxn=10;//这太神奇了 > maxlongint=1000000; > > var > a:array[1..maxn,1..maxn] of longint; > n,i,j,d,x,y,max,min,mini:longint; > > procedure floyd; > var > i,j,k:longint; > begin > for k:=1 to n do > for i:=1 to n do > for j:=1 to n do > if (a[i,k]+a[k,j]<a[i,j]) then a[i,j]:=a[i,k]+a[k,j]; > end; > > begin > readln(n); > while n<>0 do > begin > fillchar(a,sizeof(a),0); > > for i:=1 to n do > for j:=1 to n do > if (i<>j) then a[i,j]:=maxlongint > else a[i,j]:=0; > > for i:=1 to n do > begin > read(d); > > for j:=1 to d do > begin > read(x,y); > a[i,x]:=y; > end; > end; > > floyd; > > min:=maxlongint; mini:=0; > for i:=1 to n do > begin > max:=0; > for j:=1 to n do > if a[i,j]>max then max:=a[i,j]; > > if (max<>maxlongint) and (max<min) then > begin > min:=max; mini:=i; > end; > end; > if min<>maxlongint then > writeln(mini,' ',min) > else > writeln('disjoint'); > > readln(n); > end; > end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator