結果

問題 No.424 立体迷路
ユーザー mkawa2mkawa2
提出日時 2019-12-29 19:14:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 549 ms / 2,000 ms
コード長 1,569 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 44,732 KB
最終ジャッジ日時 2024-04-24 02:40:39
合計ジャッジ時間 17,351 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 549 ms
44,596 KB
testcase_01 AC 547 ms
44,600 KB
testcase_02 AC 547 ms
44,464 KB
testcase_03 AC 544 ms
44,348 KB
testcase_04 AC 543 ms
44,348 KB
testcase_05 AC 544 ms
44,348 KB
testcase_06 AC 543 ms
44,472 KB
testcase_07 AC 542 ms
44,604 KB
testcase_08 AC 544 ms
44,592 KB
testcase_09 AC 545 ms
44,348 KB
testcase_10 AC 539 ms
44,472 KB
testcase_11 AC 546 ms
44,488 KB
testcase_12 AC 546 ms
44,600 KB
testcase_13 AC 547 ms
44,472 KB
testcase_14 AC 538 ms
44,360 KB
testcase_15 AC 540 ms
44,600 KB
testcase_16 AC 530 ms
44,464 KB
testcase_17 AC 536 ms
44,604 KB
testcase_18 AC 533 ms
44,460 KB
testcase_19 AC 531 ms
44,344 KB
testcase_20 AC 531 ms
44,600 KB
testcase_21 AC 534 ms
44,340 KB
testcase_22 AC 534 ms
44,732 KB
testcase_23 AC 533 ms
44,468 KB
testcase_24 AC 534 ms
44,604 KB
testcase_25 AC 539 ms
44,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *
from bisect import *
#from math import *
from collections import *
from heapq import *
from random import *
from decimal import *
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
int2 = lambda x: int(x) +1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MI2(): return map(int2, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def dfs(i,j):
        if (i,j)==(gi,gj):return True
        h0=t[i][j]
        t[i][j]=-1
        for di,dj in dij:
            ni,nj=i+di,j+dj
            ni2,nj2=i+di*2,j+dj*2
            h1=t[ni][nj]
            if h1!=-1 and -1<=h0-h1<=1:
                if dfs(ni,nj):return True
            h2=t[ni2][nj2]
            if h2!=-1 and h2==h0 and h2>h1:
                if dfs(ni2,nj2):return True
        return False

    h,w=MI()
    si,sj,gi,gj=MI2()
    t=[[100]*(w+4) for _ in range(2)]+[[100,100]+[int(c) for c in input()]+[100,100] for _ in range(h)]+[[100]*(w+4) for _ in range(2)]
    #p2D(t)
    if dfs(si,sj):print("YES")
    else:print("NO")
    #p2D(t)

main()
0