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 |
我快疯了 help me{ ID:wudired3 LANG:PASCAL PROG:agrinet } program prim; var i,j,k,q,n,m,sum:longint; a:array[0..101,0..101]of longint; d:array[0..101]of longint; b:array[0..101]of boolean; begin while not eof do begin read(n); sum:=0; fillchar(a,sizeof(a),0); for i:=1 to n do begin for j:=1 to n do read(a[i,j]); end; for i:=1 to n do d[i]:=a[1,i]; fillchar(b,sizeof(b),1); b[1]:=false; for i:=1 to n-1 do begin m:=maxlongint; for j:=1 to n do if b[j] and(d[j]<m) then begin k:=j; m:=d[j]; end; inc(sum,m); b[k]:=false; for j:=1 to n do if b[j] and(a[k,j]<d[j]) then d[j]:=a[k,j]; end; writeln(sum); end; end. 这道题USACO上能过。。。我改多组数据了。。PRIM 我从高一开始写 写了至少50遍。。。。。我快疯了 help me Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator