結果

問題 No.323 yuki国
ユーザー lloyzlloyz
提出日時 2023-10-18 00:11:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,317 ms / 5,000 ms
コード長 927 bytes
コンパイル時間 980 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 140,644 KB
最終ジャッジ日時 2023-10-18 00:11:48
合計ジャッジ時間 21,997 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
58,940 KB
testcase_01 AC 59 ms
66,292 KB
testcase_02 AC 44 ms
58,940 KB
testcase_03 AC 94 ms
77,128 KB
testcase_04 AC 60 ms
68,336 KB
testcase_05 AC 70 ms
72,508 KB
testcase_06 AC 58 ms
68,332 KB
testcase_07 AC 43 ms
58,940 KB
testcase_08 AC 1,033 ms
136,976 KB
testcase_09 AC 1,083 ms
137,016 KB
testcase_10 AC 45 ms
58,940 KB
testcase_11 AC 54 ms
64,212 KB
testcase_12 AC 54 ms
64,212 KB
testcase_13 AC 1,105 ms
138,780 KB
testcase_14 AC 1,065 ms
138,780 KB
testcase_15 AC 644 ms
127,180 KB
testcase_16 AC 1,011 ms
138,352 KB
testcase_17 AC 1,150 ms
138,916 KB
testcase_18 AC 315 ms
93,540 KB
testcase_19 AC 652 ms
113,448 KB
testcase_20 AC 1,275 ms
139,232 KB
testcase_21 AC 1,317 ms
140,644 KB
testcase_22 AC 1,283 ms
140,168 KB
testcase_23 AC 1,233 ms
139,240 KB
testcase_24 AC 688 ms
127,188 KB
testcase_25 AC 624 ms
125,456 KB
testcase_26 AC 1,131 ms
138,824 KB
testcase_27 AC 1,126 ms
138,920 KB
testcase_28 AC 1,168 ms
138,816 KB
testcase_29 AC 1,146 ms
138,964 KB
testcase_30 AC 42 ms
58,940 KB
testcase_31 AC 56 ms
66,284 KB
testcase_32 AC 68 ms
73,044 KB
testcase_33 AC 54 ms
66,264 KB
testcase_34 AC 70 ms
73,048 KB
testcase_35 AC 42 ms
58,940 KB
testcase_36 AC 63 ms
70,440 KB
testcase_37 AC 61 ms
68,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

h, w = map(int, input().split())
a, si, sj = map(int, input().split())
b, ti, tj = map(int, input().split())
S = [list(input()) for _ in range(h)]

visited = [[[False for _ in range(2001)] for _ in range(w)] for _ in range(h)]
Directions = [(1, 0), (0, 1), (-1, 0), (0, -1)]
Que = deque([(a, si, sj)])
visited[si][sj][a] = True
while Que:
    cs, ci, cj = Que.popleft()
    for di, dj in Directions:
        ni, nj = ci + di, cj + dj
        if 0 <= ni < h and 0 <= nj < w:
            if S[ni][nj] == '.':
                ns = cs - 1
                if ns == 0:
                    continue
            else:
                ns = cs + 1
                if ns > 2000:
                    continue
            if visited[ni][nj][ns]:
                continue
            visited[ni][nj][ns] = True
            Que.append((ns, ni, nj))
if visited[ti][tj][b]:
    print("Yes")
else:
    print("No")
0