結果
| 問題 | No.2692 How Many Times Reached? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-22 22:37:25 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 896 bytes | 
| コンパイル時間 | 2,361 ms | 
| コンパイル使用メモリ | 201,632 KB | 
| 最終ジャッジ日時 | 2025-02-20 12:08:37 | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 43 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
void solve() {
  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  vector a(n, vector<ll>(n, 0));
  rep(i, n) rep(j, n) {
    if (s[i][j] == 'A')
      a[i][j] = 1;
    else if (s[i][j] == 'B')
      a[i][j] = -1;
  }
  ll ans = 0;
  rep(i, n) {
    ll now = 0;
    rep(j, n) now += a[i][j];
    ans += now == n - 1;
  }
  rep(j, n) {
    ll now = 0;
    rep(i, n) now += a[i][j];
    ans += now == n - 1;
  }
  {
    ll now = 0;
    rep(i, n) now += a[i][i];
    ans += now == n - 1;
  }
  {
    ll now = 0;
    rep(i, n) now += a[i][n - i - 1];
    ans += now == n - 1;
  }
  cout << ans << '\n';
}
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
            
            
            
        