結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 WA -
testcase_03 AC 39 ms
53,460 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 39 ms
53,460 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 39 ms
53,460 KB
testcase_14 WA -
testcase_15 AC 39 ms
53,460 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 39 ms
53,460 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 106 ms
75,700 KB
testcase_35 AC 78 ms
75,580 KB
testcase_36 AC 82 ms
75,580 KB
testcase_37 AC 67 ms
70,572 KB
testcase_38 AC 81 ms
75,576 KB
testcase_39 AC 97 ms
75,576 KB
testcase_40 AC 81 ms
75,564 KB
testcase_41 AC 73 ms
72,632 KB
testcase_42 AC 90 ms
75,568 KB
testcase_43 AC 103 ms
75,576 KB
testcase_44 AC 56 ms
65,868 KB
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def count_reaches(N, board):
    dx = [-1, -1, -1, 0, 0, 1, 1, 1]
    dy = [-1, 0, 1, -1, 1, -1, 0, 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(8):
                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