結果
問題 |
No.2692 How Many Times Reached?
|
ユーザー |
|
提出日時 | 2024-03-22 22:13:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,085 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 76,032 KB |
最終ジャッジ日時 | 2024-09-30 11:42:09 |
合計ジャッジ時間 | 3,846 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 WA * 15 |
ソースコード
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): if dir == 2 and i != 0 and j != 0: continue if dir == 3 and i != 0 and j != N-1: continue 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))