結果
| 問題 |
No.323 yuki国
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-17 23:20:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,100 bytes |
| コンパイル時間 | 797 ms |
| コンパイル使用メモリ | 82,852 KB |
| 実行使用メモリ | 435,244 KB |
| 最終ジャッジ日時 | 2024-12-20 15:27:03 |
| 合計ジャッジ時間 | 53,909 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 21 WA * 11 |
ソースコード
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())
sx -= 1
sy -= 1
B,gx,gy = map(int,input().split())
gx -= 1
gy -= 1
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')