結果
| 問題 |
No.2692 How Many Times Reached?
|
| コンテスト | |
| ユーザー |
dp_ijk
|
| 提出日時 | 2024-03-22 21:36:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 813 bytes |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 82,776 KB |
| 実行使用メモリ | 66,048 KB |
| 最終ジャッジ日時 | 2024-09-30 11:02:59 |
| 合計ジャッジ時間 | 3,792 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
def decode(ch):
if ch == "A":
return 1
if ch == "B":
return 2
return 0
def transpose(A):
H, W = len(A), len(A[0])
return [[A[i][j] for i in range(H)] for j in range(W)]
DIR4 = [(1, 0), (0, 1), (-1, 0), (0, -1)]
DIR8 = DIR4 + [(1, 1), (1, -1), (-1, -1), (-1, 1)]
N = int(input())
S = [[decode(ch) for ch in input()] for i in range(N)]
from collections import Counter
def is_good(C):
return C[1] == N-1 and C[2] == 0
def check_rows(A):
H, W = len(A), len(A[0])
res = 0
for i in range(H):
row = A[i]
C = Counter(row)
res += is_good(C)
return res
a1 = check_rows(S)
a2 = check_rows(transpose(S))
ans = a1+a2
d1 = Counter([S[i][i] for i in range(N)])
d2 = Counter([S[i][N-1-i] for i in range(N)])
ans += is_good(d1) + is_good(d2)
print(ans)
dp_ijk