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!!!program pku1258; var n,i,j,k,min,m,d,s,o:longint; a:array[1..100,1..100]of longint; b:array[1..100,1..3]of longint; t:array[1..3]of longint; begin while not(eof)do begin read(n); s:=0; fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); for i:=1 to n do begin for j:=1 to n do begin read(a[i,j]); if a[i,j]=0 then a[i,j]:=maxlongint; end; end; for i:=1 to n-1 do begin b[i,1]:=1; b[i,2]:=i+1; b[i,3]:=a[1,i+1]; end; for k:=1 to n-1 do begin min:=maxlongint; m:=k; for j:=k to n-1 do if b[j,3]<min then begin min:=b[j,3]; m:=j; end; s:=s+min; if k<>m then begin t:=b[k]; b[k]:=b[m]; b[m]:=t; end; j:=b[k,2]; for i:=k+1 to n-1 do begin d:=b[i,2]; o:=a[d,j]; if o<b[i,3] then begin b[i,1]:=j; b[i,3]:=o; end; end; end; writeln(s); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator