結果

問題 No.424 立体迷路
ユーザー tomatonosuketomatonosuke
提出日時 2016-09-25 03:43:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,161 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 108,324 KB
最終ジャッジ日時 2024-04-29 09:11:53
合計ジャッジ時間 4,924 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def examine(x,y):
    if x < 0 or y < 0 or x >= width or y >= height:
        return False
    elif got[y][x] == 1:
        return False
    else:
        return True

def path(x,y):
        got[y][x] = 1
        value = targ[y][x]
        queue = []
        for a,b in ([[x+1,y],[x-1,y],[x,y+1],[x,y-1]]):
            if examine(a,b) and (targ[b][a] == value - 1 or targ[b][a] == value + 1 or targ[b][a] == value):
                queue.append([a,b])
        for c,d,e,f in ([[x+2,y,x+1,y],[x-2,y,x-1,y],[x,y+2,x,y+1],[x,y-2,x,y-1]]):
            if examine(c,d) and targ[d][c] == value and targ[f][e] < value:
                queue.append([c,d])
        return queue

height,width = (int(n) for n in input().split(' '))
iniy,inix,endy,endx = (int(n) - 1 for n in input().split(' '))
targ = []
for h in range(height):
    targ.append([int(n) for n in input()])
got = [[0 for w in range(width)] for h in range(height)]
queue = [[inix,iniy]]

while queue != []:
    #print(queue)
    nextqueue = []
    for x,y in queue:
        temp = path(x,y)
        nextqueue.extend(temp)
    queue = nextqueue
if got[endy][endx] == 0:
    print("NO")
else:
    print("YES")
0