結果

問題 No.424 立体迷路
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-21 15:09:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-05-04 03:59:01
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 26 ms
10,880 KB
testcase_06 AC 24 ms
10,880 KB
testcase_07 AC 27 ms
10,880 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 26 ms
10,880 KB
testcase_11 AC 25 ms
10,880 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 26 ms
10,880 KB
testcase_14 AC 27 ms
10,752 KB
testcase_15 AC 27 ms
10,880 KB
testcase_16 AC 26 ms
10,880 KB
testcase_17 AC 27 ms
10,880 KB
testcase_18 AC 26 ms
10,880 KB
testcase_19 AC 28 ms
10,752 KB
testcase_20 AC 27 ms
10,880 KB
testcase_21 AC 26 ms
10,752 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 58 ms
11,008 KB
testcase_25 AC 59 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
h,w=map(int,input().split())
sy,sx,gy,gx=map(int,input().split())
sy-=1;sx-=1;gy-=1;gx-=1
g=[list(input()) for _ in range(h)]
visit=[[False]*w for _ in range(h)]
q=deque()
q.append((sy,sx))
while q:
    y,x=q.popleft()
    if visit[y][x]:
        continue
    visit[y][x]=True
    dy=[-1,0,1,0]
    dx=[0,-1,0,1]
    for i in range(4):
        ny=y+dy[i]
        nx=x+dx[i]
        if not (0<=ny<h and 0<=nx<w):
            continue
        if abs(int(g[ny][nx])-int(g[y][x]))>1:
            continue
        if visit[ny][nx]:
            continue
        q.append((ny,nx))
    dy2=[-2,0,2,0]
    dx2=[0,-2,0,2]
    for i in range(4):
        ny2=y+dy2[i]
        nx2=x+dx2[i]
        if not (0<=ny2<h and 0<=nx2<w):
            continue
        if int(g[ny2][nx2])!=int(g[y][x]):
            continue
        if int(g[(ny+y)//2][(nx+x)//2])>int(g[y][x]):
            continue
        q.append((ny2,nx2))
print('YES' if visit[gy][gx] else 'NO')
0