結果

問題 No.2692 How Many Times Reached?
ユーザー soldraysoldray
提出日時 2024-03-26 21:44:43
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,340 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 159,816 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-26 21:44:48
合計ジャッジ時間 4,535 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 13 ms
6,676 KB
testcase_35 AC 5 ms
6,676 KB
testcase_36 AC 25 ms
6,676 KB
testcase_37 AC 92 ms
6,676 KB
testcase_38 AC 72 ms
6,676 KB
testcase_39 AC 65 ms
6,676 KB
testcase_40 AC 12 ms
6,676 KB
testcase_41 AC 26 ms
6,676 KB
testcase_42 AC 25 ms
6,676 KB
testcase_43 AC 9 ms
6,676 KB
testcase_44 AC 104 ms
6,676 KB
testcase_45 AC 2 ms
6,676 KB
testcase_46 AC 92 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

#define yn(pope) (pope ? "Yes" : "No")

#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rrep(i, n, m) for (int i = (n); i > m; i--)

#define IINF (1 << 30)
#define INF (1ll << 60)

#define all(v) v.begin(), v.end()

int main() {
  int N;
  cin >> N;

  vector M(N, vector(N, '.'));

  rep(i, 0, N) {
    rep(j, 0, N) { cin >> M[j][i]; }
  }

  auto hori = [&]() -> int {
    int count = 0;

    rep(i, 0, N) {
      int c = 0;

      rep(j, 0, N) {
        if (M[j][i] == 'A') { c++; }
      }

      count += (c == N);
    }

    return count;
  };

  auto vert = [&]() -> int {
    int count = 0;

    rep(j, 0, N) {
      int c = 0;

      rep(i, 0, N) {
        if (M[j][i] == 'A') { c++; }
      }

      count += (c == N);
    }

    return count;
  };

  auto diag = [&]() -> int {
    int count = 0, c = 0;

    rep(i, 0, N) {
      if (M[i][i] == 'A') { c++; }
    }

    count += (c == N);

    c = 0;

    rep(i, 0, N) {
      if (M[N - 1 - i][i] == 'A') { c++; }
    }

    count += (c == N);

    return count;
  };

  int ans = 0;

  rep(i, 0, N) {
    rep(j, 0, N) {
      if (M[j][i] != '.') { continue; }

      M[j][i] = 'A';
      ans += (hori() + vert() + diag());
      M[j][i] = '.';
    }
  }

  cout << ans << endl;

  return 0;
}
0