前言
显然是一道shabi结论题
解法
求出 \(A\) , \(B\) 的异或矩阵,记录每一行,每一列异或和, 异或和为奇数显然不行;
Code
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 510;
int n, m, a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], x[maxn], y[maxn];
int read()
{
int x = 0, ch = getchar(), f = 1;
while(!isdigit(ch)){if(ch == '-') f = -1; ch = getchar(); }
while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
int main()
{
// freopen(".in","r",stdin); freopen(".out","w",stdout);
// int n = (8^9);
// int m = (9^10);
// std::cout<<(8^9)<<" "<<n<<" "<<m<<" "<<(9^10);
n = read(), m = read();
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= m; ++j)
{
a[i][j] = read();
}
}
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= m; ++j)
{
b[i][j] = read();
}
}
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= m; ++j)
{
c[i][j] = a[i][j]^b[i][j];
x[i] += c[i][j];
y[j] += c[i][j];
}
}
for(int i = 1; i <= n; ++i) if(x[i]&1){ puts("No"); return 0;}
for(int i = 1; i <= m; ++i) if(y[i]&1){ puts("No"); return 0;}
puts("Yes");
return 0;
}