結果
問題 | No.424 立体迷路 |
ユーザー | yn |
提出日時 | 2016-10-25 23:56:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 1,369 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 87,224 KB |
実行使用メモリ | 76,812 KB |
最終ジャッジ日時 | 2023-09-18 16:57:34 |
合計ジャッジ時間 | 3,367 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,572 KB |
testcase_01 | AC | 72 ms
71,428 KB |
testcase_02 | AC | 72 ms
71,328 KB |
testcase_03 | AC | 71 ms
71,108 KB |
testcase_04 | AC | 73 ms
71,180 KB |
testcase_05 | AC | 72 ms
71,212 KB |
testcase_06 | AC | 71 ms
71,236 KB |
testcase_07 | AC | 73 ms
71,328 KB |
testcase_08 | AC | 72 ms
71,028 KB |
testcase_09 | AC | 73 ms
71,112 KB |
testcase_10 | AC | 72 ms
71,324 KB |
testcase_11 | AC | 71 ms
71,244 KB |
testcase_12 | AC | 74 ms
71,556 KB |
testcase_13 | AC | 74 ms
71,540 KB |
testcase_14 | AC | 72 ms
71,364 KB |
testcase_15 | AC | 71 ms
71,432 KB |
testcase_16 | AC | 72 ms
71,228 KB |
testcase_17 | AC | 73 ms
71,244 KB |
testcase_18 | AC | 72 ms
71,232 KB |
testcase_19 | AC | 72 ms
71,216 KB |
testcase_20 | AC | 74 ms
71,192 KB |
testcase_21 | AC | 73 ms
71,244 KB |
testcase_22 | AC | 73 ms
71,312 KB |
testcase_23 | AC | 72 ms
71,152 KB |
testcase_24 | AC | 99 ms
76,696 KB |
testcase_25 | AC | 98 ms
76,812 KB |
ソースコード
h, w = map(int,input().split()) sx, sy, gx, gy = map(int,input().split()) sx -= 1 sy -= 1 gx -= 1 gy -= 1 b = [list(input()) for j in range(h)] dx = [ 1, 0,-1, 0] dy = [ 0, 1, 0,-1] ddx = [2, 0,-2, 0] ddy = [0, 2, 0,-2] visited = [[False] * w for j in range(h)] visited[sx][sy] = True qx = [] qy = [] qx.append(sx) qy.append(sy) while len(qx) != 0: curx = qx.pop(0) cury = qy.pop(0) cur = int(b[curx][cury]) for i in range(4): nextx = curx + dx[i] nexty = cury + dy[i] if 0 <= nextx < h and 0 <= nexty < w: pass else: continue if abs(cur - int(b[nextx][nexty])) <= 1: if not visited[nextx][nexty]: visited[nextx][nexty] = True qx.append(nextx) qy.append(nexty) for i in range(4): nextx = curx + ddx[i] nexty = cury + ddy[i] if 0 <= nextx < h and 0 <= nexty < w: pass else: continue if cur != int(b[nextx][nexty]): continue valleyx = curx + dx[i] valleyy = cury + dy[i] if int(b[valleyx][valleyy]) < cur: if not visited[nextx][nexty]: visited[nextx][nexty] = True qx.append(nextx) qy.append(nexty) if visited[gx][gy]: print("YES") else: print("NO")