結果
問題 |
No.424 立体迷路
|
ユーザー |
|
提出日時 | 2016-09-25 03:43:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,161 bytes |
コンパイル時間 | 116 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 118,588 KB |
最終ジャッジ日時 | 2024-11-18 11:21:14 |
合計ジャッジ時間 | 7,662 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 19 TLE * 2 |
ソースコード
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")