結果

問題 No.2692 How Many Times Reached?
ユーザー Rikuoh
提出日時 2024-03-22 23:28:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,324 bytes
コンパイル時間 4,144 ms
コンパイル使用メモリ 256,900 KB
最終ジャッジ日時 2025-02-20 12:43:18
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define rrep(i,a,b) for(int i = a; i >= b; --i)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const int MOD = 998244353;


int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,0,n)cin >> s[i];
  int ans = 0;
  
  rep(i,0,n){
    if(count(all(s[i]),'A') == n-1 && count(all(s[i]),'.') == 1) ans++;
  }
  vector<string> t(n);
  rep(i,0,n){
    rep(j,0,n){
      t[i].push_back(s[j][i]);
    }
  }
  
  rep(i,0,n){
    if(count(all(t[i]),'A') == n-1 && count(all(t[i]),'.') == 1) ans++;
  }

  string u;
  rep(i,0,n){
    rep(j,i,n){
      u.push_back(s[i][j]);
      break;
    }
  }
  if(count(all(u),'A') == n-1 && count(all(u),'.') == 1) ans++;

  vector<string> w(n);
  w = s;
  rep(i,0,n){
    reverse(all(w[i]));
  }
  string v;

  rep(i,0,n){
    rep(j,i,n){
      v.push_back(w[i][j]);
      break;
    }
  }

  if(count(all(v),'A') == n-1 && count(all(v),'.') == 1) ans++;


  cout << ans << endl;


  return 0;
}
0