結果

問題 No.323 yuki国
ユーザー H3PO4
提出日時 2020-08-26 09:44:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 430,736 KB
最終ジャッジ日時 2024-11-07 00:23:14
合計ジャッジ時間 7,976 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 1 WA * 1 TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

import itertools
from collections import deque
H, W = map(int, input().split())
A, Si, Sj = map(int, input().split())
B, Gi, Gj = map(int, input().split())
M = [input() for _ in range(H)]
def point2int(h, w, x):
"""
H*W*1200
(h,w,x) → 1200*W*h+1200*w+x
"""
return 1200 * W * h + 1200 * w + x
Graph = [[] for _ in range(H * W * 1200)]
for h, w in itertools.product(range(H), range(W)):
n = (1 if M[h][w] == '*' else -1)
#
for dh, dw in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
if 0 <= h - dh < H and 0 <= w - dw < W:
for x in range(1200):
if 0 <= x - n < 1200:
Graph[point2int(h - dh, w - dw, x - n)].append(point2int(h, w, x))
S = point2int(Si, Sj, A)
G = point2int(Gi, Gj, B)
# dfs
d = deque([S])
visited = [False] * (H * W * 1200)
while d:
v = d.pop()
if v == G:
print('Yes')
break
visited[v] = True
for x in Graph[v]:
if not visited[x]:
d.append(x)
else:
print('No')
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0