讨论 / 文化之旅——把废话整理一下就是dijkstra,就是Floyed,就是spfa,不用优化
vook 2014-05-17 14: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;

查看更多回复
提交回复