結果

問題 No.2692 How Many Times Reached?
ユーザー a01sa01to
提出日時 2024-04-08 00:05:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 2,939 ms
コンパイル使用メモリ 249,404 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-01 04:48:52
合計ジャッジ時間 4,411 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector Grid(n, vector<char>(n));
  rep(i, n) rep(j, n) cin >> Grid[i][j];
  int ans = 0;
  const int INF = 1e9;
  // yoko
  rep(i, n) {
    int cnt = 0;
    rep(j, n) {
      if (Grid[i][j] == 'B') cnt = INF;
      if (Grid[i][j] == '.') cnt++;
    }
    if (cnt <= 1) ans++;
  }
  // tate
  rep(j, n) {
    int cnt = 0;
    rep(i, n) {
      if (Grid[i][j] == 'B') cnt = INF;
      if (Grid[i][j] == '.') cnt++;
    }
    if (cnt <= 1) ans++;
  }
  // naname 1
  int cnt1 = 0;
  rep(i, n) {
    if (Grid[i][i] == 'B') cnt1 = INF;
    if (Grid[i][i] == '.') cnt1++;
  }
  if (cnt1 <= 1) ans++;
  // naname 2
  int cnt2 = 0;
  rep(i, n) {
    if (Grid[i][n - 1 - i] == 'B') cnt2 = INF;
    if (Grid[i][n - 1 - i] == '.') cnt2++;
  }
  if (cnt2 <= 1) ans++;
  cout << ans << endl;
  return 0;
}
0