var t,ii,i,j,n,cost,top,tail,min,tt,ttf:longint;
pre,d:array[1..1000]of longint;
b:array[1..10000]of longint;
flag:array[1..1000]of boolean;
f,c:array[1..200,1..200]of longint;
begin
read(t);
for ii:=1 to t do
begin
fillchar(f,sizeof(f),0);
fillchar(c,sizeof(c),0);
read(n);
for i:=2 to n+1 do
for j:=n+2 to n+n+1 do
begin
read(c[i,j]);
c[j,i]:=-c[i,j];
f[i,j]:=1;
f[j,i]:=0;
end;
for i:=1 to n do
for j:=1 to n do
read(tt);
for i:=2 to n+1 do
begin
c[1,i]:=0;
c[i,1]:=0;
f[1,i]:=1;
f[i,1]:=0;
end;
for i:=n+2 to 2*n+1 do
begin
c[i,2*n+2]:=0;
c[2*n+2,i]:=0;
f[i,2*n+2]:=1;
f[2*n+2,i]:=0;
end;
ttf:=0;
cost:=0;
while true do begin
top:=1;tail:=1;
b[top]:=1;
fillcha
二分图最佳匹配(网络流)
最新推荐文章于 2021-12-07 18:18:41 发布