关于AT的C
  • 板块灌水区
  • 楼主aldol_reaction
  • 当前回复5
  • 已保存回复5
  • 发布时间2021/2/6 23:10
  • 上次更新2023/11/5 03:37:21
查看原帖
关于AT的C
393190
aldol_reaction楼主2021/2/6 23:10

看了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;
}
2021/2/6 23:10
加载中...