原文:
One can notice that the operation does not change the total parity of the matrix. So, if the total parity of AA and BB do not match, then the answer is No. However, this is not the only case when the answer is no.
You can also notice that the operation does not change the total parity of each row/column independently. Thus, if in at least one row or column the parity of AA and BB do not match, then the answer is No. It turns out that if all these parities match, then the answer is Yes.
We will prove this constructing a sequence of operations that transforms AA to BB whenever parities in all rows and column match. Let's perform an operation (1,1,x,y)(1,1,x,y) for all such x>1x>1 and y>1y>1 that Axy≠BxyAxy≠Bxy. After all these operations the whole matrices except maybe the first column and the first row match. But the first column and the first row also match because of the parity! So AA is now BB.
解读 :
前提条件:整体奇偶性相同,各行奇偶性相同,各列奇偶性相同。
operatxon (1,1,x,y) 不会改变整体的奇偶性,不会改变每一行的奇偶性,不会改变每一列的奇偶性。
那么,当我对所有的A[x][y](x>1&&y>1,A[x][y]!=B[x][y])执行operatxon (1,1,x,y)后,首先这些原本和B[x][y]不同的A[x][y]会变得和B[x][y]相同。
然后从行奇偶性相同的角度出发,对于第p行(p>1)来说,A[p][y]=B[p][y](y>1),由于有行奇偶性相同,则一定会使A[p][1]=B[p][1].
从列奇偶性相同的角度出发,对于第p列(p>1)来说,A[x][p]=B[x][p](x>1),由于有列奇偶性相同,则一定会使 A[1][p]=B[1][p].
对于A[1][1]来说,你可以从三个角度来看是否相等,例如从整体奇偶性来看,我们已经证明A[x][y]=B[x][y](x!=1&&y!=1),那么由于有整体奇偶性相同,则一定会使A[1][1]=B[1][1].
-----------------
话说,行列奇偶性相同,是不是意味着整体奇偶性相同呢?
答:从一方考虑就行了,如果行列奇偶性混合考虑起来会很混乱。
行奇偶性相同,则整体奇偶性相同:
整体奇偶性=sum(各行奇偶性)
列奇偶性相同,则整体奇偶性相同:
整体奇偶性=sum(各列奇偶性)