代码:
#include<iostream>
using namespace std ;
int main ()
{
int row , line ; //记录矩阵的行数,列数
while (scanf("%d%d",&row,&line) && (row+line)!=0)
{
int s1=0,s2=0; //分别记录黑白格子数目
for(int i=0;i<row;i++)
{
for (int j=0;j<line;j++)
{
int num;
cin >> num;
if((i+j)%2==0)
s1+=num;
else
s2+=num;
}
}
if(s1==s2)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0 ;
}