You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
821 B
C++
32 lines
821 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N = 505;
|
|
int a[N][N];
|
|
int main()
|
|
{
|
|
int n, m;
|
|
scanf("%d%d", &n, &m);
|
|
for (int _ = 0, x; _ < 2; _++)
|
|
for (int i = 0; i < n; i++)
|
|
for (int j = 0; j < m; j++)
|
|
scanf("%d", &x), a[i][j] ^= x;
|
|
for (int i = 1; i < n; i++)
|
|
for (int j = 1; j < m; j++)
|
|
if (a[i][j])
|
|
{
|
|
a[0][0] ^= 1;
|
|
a[i][0] ^= 1;
|
|
a[0][j] ^= 1;
|
|
a[i][j] ^= 1;
|
|
}
|
|
int cnt = 0;
|
|
for (int i = 0; i < n; i++)
|
|
cnt += a[i][0];
|
|
for (int j = 0; j < n; j++)
|
|
cnt += a[0][j];
|
|
puts(cnt ? "No" : "Yes");
|
|
return 0;
|
|
}
|