18、19、20都错了
不只有没有数据
没理由错啊
const ss:array[1..9,1..9] of longint=
((6,6,6,6,6,6,6,6,6),
(6,7,7,7,7,7,7,7,6),
(6,7,8,8,8,8,8,7,6),
(6,7,8,9,9,9,8,7,6),
(6,7,8,9,10,9,8,7,6),
(6,7,8,9,9,9,8,7,6),
(6,7,8,8,8,8,8,7,6),
(6,7,7,7,7,7,7,7,6),
(6,6,6,6,6,6,6,6,6));
var
i,j,max,e,x,y,k,t1:longint;
w1:array[0..9] of longint;
a:array[1..9,1..9] of longint;
h,l,s:array[1..9,1..9] of boolean;
w:array[1..9,0..9] of longint;
procedure try(o,p:longint);
var x,y,i,z:longint;
begin
if o=10 then
begin
if p<max then max:=p;
exit;
end;
x:=w1[o];
if w[x,0]=0 then try(o+1,p)
else
begin
y:=w[x,w[x,0]];
for i:=1 to 9 do
if (h[x,i]=false)and(l[y,i]=false)and(s[(x-1)div 3*3+(y-1)div 3+1,i]=false) then
begin
h[x,i]:=true;l[y,i]:=true;s[(x-1)div 3*3+(y-1)div 3+1,i]:=true;
dec(w[x,0]);a[x,y]:=i;
z:=p+100-i*ss[x,y];
if z<max then try(o,z);
inc(w[x,0]);
h[x,i]:=false;l[y,i]:=false;s[(x-1)div 3*3+(y-1)div 3+1,i]:=false;
end;
end;
end;
begin
for i:=1 to 9 do
for j:=1 to 9 do
begin
read(a[i,j]);
if a[i,j]<>0 then
begin
h[i,a[i,j]]:=true;
l[j,a[i,j]]:=true;
inc(e,100-a[i,j]*ss[i,j]);
end
else
begin
inc(w[i,0]);w[i,w[i,0]]:=j;
end;
end;
for i:=1 to 9 do
begin
x:=(i-1) div 3;y:=(i-1)mod 3;
for j:=x*3+1 to x*3+3 do
for k:=y*3+1 to y*3+3 do
if a[j,k]<>0 then s[i,a[j,k]]:=true;
end;
for i:=1 to 9 do w1[i]:=i;
for i:=1 to 8 do
for j:=i+1 to 9 do
if w[i,0]>w[j,0] then
begin
t1:=w1[i];w1[i]:=w1[j];w1[j]:=t1;
end;
max:=8100;
try(1,e);
if max<>8100 then writeln(8100-max) else writeln(-1);
end.