結果

問題 No.323 yuki国
ユーザー maspymaspy
提出日時 2020-03-21 12:19:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 894 ms / 5,000 ms
コード長 996 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 261,368 KB
最終ジャッジ日時 2023-08-23 11:04:32
合計ジャッジ時間 16,896 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,276 KB
testcase_01 AC 84 ms
76,404 KB
testcase_02 AC 74 ms
71,200 KB
testcase_03 AC 106 ms
85,396 KB
testcase_04 AC 85 ms
76,588 KB
testcase_05 AC 93 ms
77,524 KB
testcase_06 AC 86 ms
76,744 KB
testcase_07 AC 71 ms
71,144 KB
testcase_08 AC 707 ms
232,688 KB
testcase_09 AC 658 ms
240,348 KB
testcase_10 AC 71 ms
71,436 KB
testcase_11 AC 81 ms
76,204 KB
testcase_12 AC 81 ms
76,544 KB
testcase_13 AC 652 ms
231,332 KB
testcase_14 AC 649 ms
231,372 KB
testcase_15 AC 467 ms
197,332 KB
testcase_16 AC 620 ms
216,532 KB
testcase_17 AC 761 ms
253,940 KB
testcase_18 AC 339 ms
134,920 KB
testcase_19 AC 445 ms
232,004 KB
testcase_20 AC 894 ms
257,820 KB
testcase_21 AC 842 ms
257,460 KB
testcase_22 AC 883 ms
261,224 KB
testcase_23 AC 873 ms
261,368 KB
testcase_24 AC 470 ms
208,320 KB
testcase_25 AC 497 ms
202,400 KB
testcase_26 AC 672 ms
231,228 KB
testcase_27 AC 667 ms
224,736 KB
testcase_28 AC 671 ms
232,012 KB
testcase_29 AC 670 ms
218,724 KB
testcase_30 AC 75 ms
71,312 KB
testcase_31 AC 84 ms
76,204 KB
testcase_32 AC 88 ms
76,476 KB
testcase_33 AC 81 ms
76,544 KB
testcase_34 AC 107 ms
77,668 KB
testcase_35 AC 73 ms
71,532 KB
testcase_36 AC 89 ms
76,776 KB
testcase_37 AC 87 ms
76,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, readline().split())
A, Sx, Sy = map(int, readline().split())
B, Gx, Gy = map(int, readline().split())

M = ''.join(read().decode().split())

S = Sx * W + Sy
G = Gx * W + Gy
N = H * W

start = A * N + S
goal = B * N + G

stack = [start]
visited = set([start])
while stack:
    v = stack.pop()
    size, xy = divmod(v, N)
    x, y = divmod(xy, W)
    for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        x1 = x + dx
        y1 = y + dy
        if not ((0 <= x1 < H) and (0 <= y1 < W)):
            continue
        xy1 = x1 * W + y1
        size1 = size - 1 + 2 * (M[xy1] == '*')
        if not size1:
            continue
        if size1 > 1500:
            continue
        v1 = size1 * N + xy1
        if v1 in visited:
            continue
        visited.add(v1)
        stack.append(v1)


print('Yes' if goal in visited else 'No')
0