結果
問題 | No.2692 How Many Times Reached? |
ユーザー |
![]() |
提出日時 | 2024-03-23 04:24:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 1,543 bytes |
コンパイル時間 | 1,613 ms |
コンパイル使用メモリ | 195,728 KB |
最終ジャッジ日時 | 2025-02-20 13:02:00 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } int ans = 0; // たて for (int j = 0; j < n; j++) { int dot_cnt = 0, b_cnt = 0; for (int i = 0; i < n; i++) { if (s[i][j] == '.') { dot_cnt++; } else if (s[i][j] == 'B') { b_cnt++; } } if (dot_cnt == 1 && b_cnt == 0) { ans++; } } // よこ for (int i = 0; i < n; i++) { int dot_cnt = 0, b_cnt = 0; for (int j = 0; j < n; j++) { if (s[i][j] == '.') { dot_cnt++; } else if (s[i][j] == 'B') { b_cnt++; } } if (dot_cnt == 1 && b_cnt == 0) { ans++; } } // ななめ int dot_cnt = 0, b_cnt = 0; for (int i = 0; i < n; i++) { if (s[i][i] == '.') { dot_cnt++; } else if (s[i][i] == 'B') { b_cnt++; } } if (dot_cnt == 1 && b_cnt == 0) { ans++; } dot_cnt = 0, b_cnt = 0; for (int i = 0; i < n; i++) { if (s[i][n - 1 - i] == '.') { dot_cnt++; } else if (s[i][n - 1 - i] == 'B') { b_cnt++; } } if (dot_cnt == 1 && b_cnt == 0) { ans++; } cout << ans << endl; }