結果

問題 No.2692 How Many Times Reached?
コンテスト
ユーザー Kou0406
提出日時 2025-03-21 10:25:25
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 807 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 425 ms
コンパイル使用メモリ 92,368 KB
実行使用メモリ 9,272 KB
最終ジャッジ日時 2026-07-07 13:50:26
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<cassert>
#define rep(i,n) for(i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int n;

int main(){
    int i,j,na1=0,na2=0;
    scanf("%d",&n);
    vector<int> row(n,0),col(n,0);
    string str;
    const int NIL=-n;
    rep(i,n){
        cin>>str;
        rep(j,n){
            if(str[j]=='A'){
                row[i]++;
                col[j]++;
                if(i==j)na1++;
                if(j==n-1-i)na2++;
            }else if(str[j]=='B'){
                row[i]=NIL;
                col[j]=NIL;
                if(i==j)na1=NIL;
                if(j==n-1-i)na2=NIL;
            }
        }
    }
    j=(na1==n-1)+(na2==n-1);
    rep(i,n)j+=(row[i]==n-1)+(col[i]==n-1);
    printf("%d\n",j);
    return 0;
}
0