結果
問題 | No.2692 How Many Times Reached? |
ユーザー |
![]() |
提出日時 | 2024-03-23 04:24:37 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,543 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 202,648 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 13:02:57 |
合計ジャッジ時間 | 2,907 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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;}