結果

問題 No.323 yuki国
ユーザー ぴろずぴろず
提出日時 2015-12-15 20:36:58
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 626 ms / 5,000 ms
コード長 848 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 77,684 KB
実行使用メモリ 116,724 KB
最終ジャッジ日時 2023-09-10 21:10:53
合計ジャッジ時間 13,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
78,116 KB
testcase_01 AC 85 ms
78,088 KB
testcase_02 AC 83 ms
77,900 KB
testcase_03 AC 106 ms
79,824 KB
testcase_04 AC 84 ms
78,204 KB
testcase_05 AC 87 ms
78,128 KB
testcase_06 AC 84 ms
78,272 KB
testcase_07 AC 84 ms
78,172 KB
testcase_08 AC 587 ms
116,332 KB
testcase_09 AC 562 ms
116,308 KB
testcase_10 AC 83 ms
78,060 KB
testcase_11 AC 93 ms
79,616 KB
testcase_12 AC 93 ms
79,856 KB
testcase_13 AC 583 ms
116,308 KB
testcase_14 AC 584 ms
116,224 KB
testcase_15 AC 502 ms
114,428 KB
testcase_16 AC 502 ms
112,212 KB
testcase_17 AC 626 ms
116,544 KB
testcase_18 AC 119 ms
79,972 KB
testcase_19 AC 339 ms
99,024 KB
testcase_20 AC 297 ms
93,056 KB
testcase_21 AC 577 ms
110,684 KB
testcase_22 AC 609 ms
111,140 KB
testcase_23 AC 585 ms
111,652 KB
testcase_24 AC 537 ms
114,040 KB
testcase_25 AC 534 ms
113,912 KB
testcase_26 AC 186 ms
87,712 KB
testcase_27 AC 190 ms
87,140 KB
testcase_28 AC 622 ms
116,724 KB
testcase_29 AC 599 ms
116,316 KB
testcase_30 AC 84 ms
78,140 KB
testcase_31 AC 84 ms
78,000 KB
testcase_32 AC 85 ms
78,412 KB
testcase_33 AC 85 ms
78,124 KB
testcase_34 AC 83 ms
77,940 KB
testcase_35 AC 83 ms
78,220 KB
testcase_36 AC 84 ms
78,172 KB
testcase_37 AC 84 ms
78,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python

from collections import deque

h,w = map(int, raw_input().split())
a,si,sj = map(int,raw_input().split())
b,gi,gj = map(int,raw_input().split())
m = [raw_input() for i in range(h)]

ma = max(a+h+w-1,b+2*(h+w))

used = [[[False] * (ma+1) for j in range(w)] for i in range(h)]

d = [0,1,0,-1]

q = deque([a << 16 | si << 8 | sj]);
used[si][sj][a] = True
while len(q) > 0:
    p = q.popleft()
    cs = p >> 16
    ci = p >> 8 & 0xff
    cj = p & 0xff
    for i in range(4):
        ni = ci + d[i]
        nj = cj + d[i^1]
        if ni < 0 or ni >= h or nj < 0 or nj >= w :
            continue
        ns = cs + (1 if m[ni][nj] == '*' else -1)
        if ns > ma or ns <= 0 or used[ni][nj][ns]:
            continue
        used[ni][nj][ns] = True
        q.append(ns << 16 | ni << 8 | nj)
print("Yes" if used[gi][gj][b] else "No")
0