显然知道第一行就可以只道整个矩阵
但n<=40,搜索是不行的,我们设第一行为x1~xm
可以由轻易由第一行未知数推出第n+1行,这一步我们可以压成二进制位(因为只和奇偶有关)
显然n+1行必须是0,由此可以列方程高斯消元即可

 var a,c:array[..,..] of longint;
b:array[..,..] of int64;
n,m,i,j:longint; procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure gauss;
var i,j,k,p:longint;
begin
k:=;
for i:= to m do
begin
j:=k;
while (j<=m) and (a[j,i]=) do inc(j);
if (j>m) then continue;
if j<>k then
begin
for p:=i to m+ do
swap(a[k,p],a[j,p]);
end;
for j:=k+ to m do
if a[j,i]= then
begin
for p:=i to m+ do
a[j,p]:=a[j,p] xor a[k,p];
end;
inc(k);
end;
for i:=m downto do
begin
c[,i]:=a[i,m+];
if a[i,i]= then
begin
c[,i]:=;
continue;
end;
for j:=i+ to m do
if a[i,j]= then c[,i]:=c[,i] xor c[,j];
end;
end; begin
readln(n,m);
for i:= to m do
b[,i]:=int64() shl int64(i-); for i:= to n+ do
for j:= to m do
b[i,j]:=b[i-,j] xor b[i-,j+] xor b[i-,j-] xor b[i-,j]; for i:= to m do
for j:= to m do
if b[n+,i] and (int64() shl int64(j-))<> then a[i,j]:=; gauss;
for i:= to n do
for j:= to m do
c[i,j]:=c[i-,j] xor c[i-,j+] xor c[i-,j-] xor c[i-,j]; for i:= to n do
begin
for j:= to m- do
write(c[i,j],' ');
writeln(c[i,m]);
end;
end.
05-11 09:41