結果
問題 | No.323 yuki国 |
ユーザー |
|
提出日時 | 2015-12-16 00:37:31 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 692 ms / 5,000 ms |
コード長 | 806 bytes |
コンパイル時間 | 510 ms |
コンパイル使用メモリ | 76,928 KB |
実行使用メモリ | 149,876 KB |
最終ジャッジ日時 | 2024-06-28 12:19:10 |
合計ジャッジ時間 | 12,567 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
from collections import dequedxy = zip([1, 0, -1, 0], [0, 1, 0, -1])H, W = map(int, raw_input().split())A, Sy, Sx = map(int, raw_input().split())B, Gy, Gx = map(int, raw_input().split())M = [raw_input() for i in xrange(H)]que = deque([(A, Sx, Sy)])used = [[[False]*51 for i in xrange(51)] for j in xrange(max(A, B) + 100)]while que:a, x, y = que.popleft()if used[a][x][y]: continueused[a][x][y] = Trueif Gx == x and Gy == y and a == B:print "Yes"breakfor dx, dy in dxy:nx, ny = x + dx, y + dyif 0 <= nx < W and 0 <= ny < H:na = a + (1 if M[ny][nx] == "*" else -1)if na <= 0 or na >= max(A, B) + 100: continueif used[na][nx][ny]: continueque.append((na, nx, ny))else:print "No"