vook 2014-05-16 23:49:31
点我顶贴
收藏
删除
整理其实很简单:
for i:=1 to n do read(c[i]);
for i:=1 to k do for j:=1 to k do read(f[i,j]);
for i:=1 to m do
begin
read(u,v,d);if c[u]=c[v] then continue;
if f[c[v],c[u]]=0 then a[u,v]:=min(d,a[u,v]);
if f[c[u],c[v]]=0 then a[v,u]:=min(d,a[v,u]);
end;
其中min():
function min(xxx,xx:longint):longint;
begin
if xxx=0 then exit(xx);if xx=0 then exit(xxx);
if xxx>xx then min:=xx else min:=xxx;
end;