看了AC代码,并不是很理解到底怎么做的,为什么这么枚举啊
#include <bits/stdc++.h>
using namespace std;
int main(){
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++){
cin >> S[i];
}
int ans = 0;
for (int i = 0; i < H - 1; i++){
for (int j = 0; j < W - 1; j++){
int cnt = 0;
for (int y = i; y <= i + 1; y++){
for (int x = j; x <= j + 1; x++){
if (S[y][x] == '#'){
cnt++;
}
}
}
if (cnt % 2 == 1){
ans++;
}
}
}
cout << ans << endl;
}