結果

問題 No.2692 How Many Times Reached?
ユーザー dp_ijkdp_ijk
提出日時 2024-03-22 21:36:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 66,268 KB
最終ジャッジ日時 2024-03-22 21:36:14
合計ジャッジ時間 4,080 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,616 KB
testcase_01 AC 41 ms
55,616 KB
testcase_02 AC 41 ms
55,616 KB
testcase_03 AC 44 ms
55,616 KB
testcase_04 AC 40 ms
55,616 KB
testcase_05 AC 41 ms
55,616 KB
testcase_06 AC 41 ms
55,616 KB
testcase_07 AC 41 ms
55,616 KB
testcase_08 AC 41 ms
55,616 KB
testcase_09 AC 42 ms
55,616 KB
testcase_10 AC 41 ms
55,616 KB
testcase_11 AC 41 ms
55,616 KB
testcase_12 AC 40 ms
55,616 KB
testcase_13 AC 41 ms
55,616 KB
testcase_14 AC 40 ms
55,616 KB
testcase_15 AC 40 ms
55,616 KB
testcase_16 AC 41 ms
55,616 KB
testcase_17 AC 40 ms
55,616 KB
testcase_18 AC 40 ms
55,616 KB
testcase_19 AC 41 ms
55,616 KB
testcase_20 AC 41 ms
55,616 KB
testcase_21 AC 41 ms
55,616 KB
testcase_22 AC 41 ms
55,616 KB
testcase_23 AC 41 ms
55,616 KB
testcase_24 AC 41 ms
55,616 KB
testcase_25 AC 44 ms
55,616 KB
testcase_26 AC 41 ms
55,616 KB
testcase_27 AC 40 ms
55,616 KB
testcase_28 AC 46 ms
55,616 KB
testcase_29 AC 45 ms
55,616 KB
testcase_30 AC 41 ms
55,616 KB
testcase_31 AC 41 ms
55,616 KB
testcase_32 AC 41 ms
55,616 KB
testcase_33 AC 41 ms
55,616 KB
testcase_34 AC 58 ms
66,256 KB
testcase_35 AC 54 ms
64,044 KB
testcase_36 AC 56 ms
66,140 KB
testcase_37 AC 55 ms
66,248 KB
testcase_38 AC 57 ms
66,268 KB
testcase_39 AC 63 ms
66,256 KB
testcase_40 AC 54 ms
64,044 KB
testcase_41 AC 52 ms
64,048 KB
testcase_42 AC 57 ms
66,268 KB
testcase_43 AC 58 ms
66,268 KB
testcase_44 AC 57 ms
64,176 KB
testcase_45 AC 41 ms
55,616 KB
testcase_46 AC 57 ms
66,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0