题意:
解法:
考虑什么情况下x和y的答案可能相同:
容易想到x和y中不同位置的数量为偶数时满足条件.
每有一个不同的位置,
x和y中1的个数的奇偶性就会变化1,
因此当x和y中1的个数的奇偶性相同时,满足条件.
题目是求不满足条件的数量,
因此我们只需要求1的个数奇偶性不同的数对数量.
统计1的个数奇数和偶数的数量,相乘就是答案.
code:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxm=2e6+5;
int n,m;
void solve(){
cin>>n>>m;
int cnt[2]={
0};
for(int i=1;i<=n;i++){
int x=0;
for(int j=1;j<=m;j++){
char c;cin>>c;
if(c=='1')x++;
}
cnt[x%2]++;
}
int ans=cnt[0]*cnt[1];
cout<<ans<<endl;
}
signed main(){
solve();
return 0;
}