結果

問題 No.323 yuki国
ユーザー H3PO4H3PO4
提出日時 2020-08-26 09:44:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 423,424 KB
最終ジャッジ日時 2024-04-24 15:47:37
合計ジャッジ時間 7,789 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
12,544 KB
testcase_01 AC 34 ms
11,136 KB
testcase_02 AC 102 ms
14,592 KB
testcase_03 AC 360 ms
32,000 KB
testcase_04 AC 52 ms
12,800 KB
testcase_05 AC 108 ms
15,872 KB
testcase_06 WA -
testcase_07 AC 119 ms
17,152 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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')
0