結果
| 問題 | No.2692 How Many Times Reached? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-22 21:25:16 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 853 bytes | 
| コンパイル時間 | 1,993 ms | 
| コンパイル使用メモリ | 195,928 KB | 
| 最終ジャッジ日時 | 2025-02-20 11:06:56 | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 43 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<string> S(N);
    for(auto &s : S) cin >> s;
    int answer = 0;
    for(int i=0; i<N; i++){
        int h = 0,w = 0;
        for(int k=0; k<N; k++){
            if(S.at(i).at(k) == '.') w++;
            if(S.at(k).at(i) == '.') h++;
            if(S.at(i).at(k) == 'B') w += 2;
            if(S.at(k).at(i) == 'B') h += 2;
        }
        if(h == 1) answer++;
        if(w == 1) answer++;
    }
    int l = 0,r = 0;
    for(int i=0; i<N; i++){
        if(S.at(i).at(i) == '.') l++;
        if(S.at(i).at(i) == 'B') l += 2;
        if(S.at(i).at(N-1-i) == '.') r++;
        if(S.at(i).at(N-1-i) == 'B') r += 2;
    }
    if(l == 1) answer++;
    if(r == 1) answer++;
    cout << answer << endl;
}
            
            
            
        