結果

問題 No.2692 How Many Times Reached?
ユーザー Kou0406
提出日時 2025-03-21 10:25:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 72,952 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-21 10:25:27
合計ジャッジ時間 2,508 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

#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