結果

問題 No.2692 How Many Times Reached?
ユーザー Ekiben542Ekiben542
提出日時 2024-03-22 22:02:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,696 KB
最終ジャッジ日時 2024-03-22 22:03:19
合計ジャッジ時間 4,141 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 38 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 38 ms
53,460 KB
testcase_08 AC 40 ms
53,460 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 WA -
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 37 ms
53,460 KB
testcase_17 AC 38 ms
53,460 KB
testcase_18 AC 38 ms
53,460 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 37 ms
53,460 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 38 ms
53,460 KB
testcase_28 WA -
testcase_29 AC 38 ms
53,460 KB
testcase_30 WA -
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 37 ms
53,460 KB
testcase_33 AC 38 ms
53,460 KB
testcase_34 AC 89 ms
75,588 KB
testcase_35 AC 67 ms
72,636 KB
testcase_36 AC 65 ms
72,632 KB
testcase_37 AC 54 ms
65,872 KB
testcase_38 AC 66 ms
72,760 KB
testcase_39 AC 88 ms
75,588 KB
testcase_40 AC 75 ms
74,172 KB
testcase_41 AC 60 ms
68,468 KB
testcase_42 AC 79 ms
75,696 KB
testcase_43 AC 85 ms
75,580 KB
testcase_44 WA -
testcase_45 AC 44 ms
59,456 KB
testcase_46 AC 66 ms
72,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def count_reaches(N, board):
    dx = [0, 1, 1, -1]
    dy = [1, 0, 1, 1]
    
    def is_valid(x, y):
        return 0 <= x < N and 0 <= y < N
    
    def check_direction(x, y, dx, dy):
        cnt_A, cnt_dot = 0, 0
        for i in range(N):
            nx, ny = x + i*dx, y + i*dy
            if not is_valid(nx, ny):
                return False
            if board[nx][ny] == 'A':
                cnt_A += 1
            elif board[nx][ny] == '.':
                cnt_dot += 1
        return cnt_A == N-1 and cnt_dot == 1
    
    cnt_reaches = 0
    for i in range(N):
        for j in range(N):
            if board[i][j] != 'A':
                continue
            for dir in range(4):
                cnt_reaches += check_direction(i, j, dx[dir], dy[dir])
    return cnt_reaches

N = int(input())

board = []
for _ in range(N):
    row = input().strip()
    board.append(row)

print(count_reaches(N, board))
0