結果

問題 No.2692 How Many Times Reached?
ユーザー aogeraaogera
提出日時 2024-03-31 08:38:52
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 2,244 bytes
コンパイル時間 4,994 ms
コンパイル使用メモリ 310,380 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 08:38:59
合計ジャッジ時間 6,244 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 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 1 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 1 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 1 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 2 ms
6,676 KB
testcase_24 AC 21 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 1 ms
6,676 KB
testcase_30 AC 1 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 1 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 2 ms
6,676 KB
testcase_38 AC 2 ms
6,676 KB
testcase_39 AC 2 ms
6,676 KB
testcase_40 AC 1 ms
6,676 KB
testcase_41 AC 2 ms
6,676 KB
testcase_42 AC 2 ms
6,676 KB
testcase_43 AC 2 ms
6,676 KB
testcase_44 AC 2 ms
6,676 KB
testcase_45 AC 1 ms
6,676 KB
testcase_46 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;using namespace atcoder;using vst = vector<string>;using ll = long long;
using ld = long double;using pll = pair<ll,ll>;using vll = vector<ll>;using vvll = vector<vll>;
using vpll = vector<pll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repp(i,k,n) for (ll i = k; i < n; i++)
#define per(i,s,e) for(ll i = s; i >= e; i--)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define no() {cout << "No" << endl; return 0;}
#define yes(){cout << "Yes" << endl;return 0;}
#define yesno(a) a ? cout << "Yes" << endl : cout << "No" << endl
#define YESNO(a) a ? cout << "YES" << endl : cout << "NO" << endl
#define MODD 998244353LL
#define MOD 1000000007LL
#define UNOmap unordered_map
#define UNOset unordered_set
#define ASC(T) T,vector<T>,greater<T>
#define join(G,a,b) G[a].push_back(b);G[b].push_back(a);
template<class... T>void in(T&... a){(cin >> ... >> a);}
template<class T, class... Ts>void out(const T& a, const Ts&... b){cout << a;((cout << ' ' <<  b), ...);cout << '\n';}
void vin(vll &v){for(ll i = 0; i < (ll)v.size(); i++)in(v[i]);}
void vout(vll &v){for(ll i = 0; i < (ll)v.size(); i++) cout << v[i] << ' ';}
ll INF = 1LL << 62;

// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// using mint = modint998244353;
// using mint = modint1000000007;
// using mint = modint;


// cout << fixed << setprecision(15);
//----------------------------------------------



int main(){
  ll N;
  in(N);
  ll ans = 0;
  
  vst s(N);
  rep(i,N) in(s[i]);
  
  
  rep(i,N){
    ll cur = 0;
    bool ok = true;
    rep(j,N){
      if(s[i][j] == 'A') cur++;
      if(s[i][j] == 'B')  ok = false;
    }
    if(cur == N-1 and ok)ans++;
  }
  
  rep(j,N){
    ll cur = 0;
    bool ok = true;
    rep(i,N){
      if(s[i][j] == 'A') cur++;
      if(s[i][j] == 'B')ok = false;
    }
    if(cur == N-1 and ok) ans++;
  }
  
  ll p = 0;
  bool flg1 = true;
  rep(i,N){
    if(s[i][i] == 'A') p++;
    if(s[i][i] == 'B')flg1 = false;
  }
  if(p == N-1 and flg1) ans++;
  
  ll q = 0;
  bool flg2 = true;
  rep(i,N){
    if(s[N-i-1][i] == 'A')q++;
    if(s[N-i-1][i] == 'B')flg2 = false;
  }
  if(q == N-1 and flg2)ans++;
  
  out(ans);
}
0