結果
問題 | No.2692 How Many Times Reached? |
ユーザー |
|
提出日時 | 2024-03-26 21:44:43 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 1,340 bytes |
コンパイル時間 | 2,026 ms |
コンパイル使用メモリ | 163,116 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 14:26:14 |
合計ジャッジ時間 | 3,644 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define yn(pope) (pope ? "Yes" : "No") #define rep(i, n, m) for (int i = (n); i < (m); i++) #define rrep(i, n, m) for (int i = (n); i > m; i--) #define IINF (1 << 30) #define INF (1ll << 60) #define all(v) v.begin(), v.end() int main() { int N; cin >> N; vector M(N, vector(N, '.')); rep(i, 0, N) { rep(j, 0, N) { cin >> M[j][i]; } } auto hori = [&]() -> int { int count = 0; rep(i, 0, N) { int c = 0; rep(j, 0, N) { if (M[j][i] == 'A') { c++; } } count += (c == N); } return count; }; auto vert = [&]() -> int { int count = 0; rep(j, 0, N) { int c = 0; rep(i, 0, N) { if (M[j][i] == 'A') { c++; } } count += (c == N); } return count; }; auto diag = [&]() -> int { int count = 0, c = 0; rep(i, 0, N) { if (M[i][i] == 'A') { c++; } } count += (c == N); c = 0; rep(i, 0, N) { if (M[N - 1 - i][i] == 'A') { c++; } } count += (c == N); return count; }; int ans = 0; rep(i, 0, N) { rep(j, 0, N) { if (M[j][i] != '.') { continue; } M[j][i] = 'A'; ans += (hori() + vert() + diag()); M[j][i] = '.'; } } cout << ans << endl; return 0; }