1 solutions
-
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
Information
- ID
- 17973
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By