因为息掉的灯是偶数就可以两两打开,而单数就不行。 例如:

11111
10101
11111

可以变成

11111
10011
11111

然后变成

11111
11111
11111

息掉的灯是单数就不行,例如

11111
10001
11111

AC Code

#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,n,m;
char flag[2010][2010];
signed main(){
	//freopen("light.in","r",stdin);
	//freopen("light.out","w",stdout);
	cin>>t;
	while(t--){
		cin>>n>>m;
		int cnt=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>flag[i][j];
				if(flag[i][j]=='0') cnt++;//记录息掉的灯掉数量
			}
		}
		if(cnt%2==0) puts("Yes");
		else puts("No");
	}
	return 0;
}