1 条题解
-
0
Pascal :
var n,i,j,k,l,r,min,total:longint; a:array[1..100]of longint; g:array[1..100,1..100]of longint; begin readln(n); for i:=1 to n do for j:=1 to n do g[i,j]:=1000000; for i:=1 to n do begin g[i,i]:=0; readln(a[i],l,r); if l>0 then begin g[i,l]:=1;g[l,i]:=1; end; if r>0 then begin g[i,r]:=1;g[r,i]:=1; end; end; for k:=1 to n do for i:=1 to n do for j:=1 to n do if g[i,k]+g[k,j]<g[i,j] then g[i,j]:=g[i,k]+g[k,j]; min:=maxlongint; for i:=1 to n do begin total:=0; for j:=1 to n do total:=total+g[i,j]*a[j]; if total<min then min:=total; end; write(min); end.
- 1
信息
- ID
- 2680
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者