結果
問題 |
No.323 yuki国
|
ユーザー |
|
提出日時 | 2024-05-17 23:31:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,308 ms / 5,000 ms |
コード長 | 1,068 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 431,604 KB |
最終ジャッジ日時 | 2024-12-20 15:33:00 |
合計ジャッジ時間 | 56,627 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
from collections import * from itertools import * from functools import * from heapq import * import sys, math input = sys.stdin.readline H,W = map(int,input().split()) A,sx,sy = map(int,input().split()) B,gx,gy = map(int,input().split()) M = [list(input())[:-1] for _ in range(H)] vis = defaultdict(lambda:False) vis[(sx,sy,A)] = True v = deque() v.append((sx,sy,A)) def nb(x,y): tmp = [] if x+1<H: tmp.append((x+1,y)) if x-1>=0: tmp.append((x-1,y)) if y+1<W: tmp.append((x,y+1)) if y-1>=0: tmp.append((x,y-1)) return tmp while v: x,y,h = v.popleft() if h>1300: continue for ix,iy in nb(x,y): if M[ix][iy]=='.': if h==1: continue if vis[(ix,iy,h-1)]: continue vis[(ix,iy,h-1)]=True v.append((ix,iy,h-1)) else: if vis[(ix,iy,h+1)]: continue vis[(ix,iy,h+1)]=True v.append((ix,iy,h+1)) if vis[(gx,gy,B)]: print('Yes') else: print('No')