結果
問題 | No.424 立体迷路 |
ユーザー | aqua_tenhou |
提出日時 | 2021-07-11 23:04:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 234 ms / 2,000 ms |
コード長 | 1,174 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 87,128 KB |
実行使用メモリ | 84,692 KB |
最終ジャッジ日時 | 2023-09-14 20:25:35 |
合計ジャッジ時間 | 7,569 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 208 ms
81,404 KB |
testcase_01 | AC | 216 ms
81,332 KB |
testcase_02 | AC | 207 ms
81,380 KB |
testcase_03 | AC | 204 ms
81,276 KB |
testcase_04 | AC | 207 ms
81,268 KB |
testcase_05 | AC | 207 ms
81,508 KB |
testcase_06 | AC | 205 ms
81,276 KB |
testcase_07 | AC | 201 ms
81,516 KB |
testcase_08 | AC | 203 ms
81,448 KB |
testcase_09 | AC | 205 ms
81,416 KB |
testcase_10 | AC | 205 ms
81,172 KB |
testcase_11 | AC | 202 ms
81,352 KB |
testcase_12 | AC | 202 ms
81,356 KB |
testcase_13 | AC | 201 ms
81,164 KB |
testcase_14 | AC | 199 ms
81,596 KB |
testcase_15 | AC | 203 ms
81,508 KB |
testcase_16 | AC | 200 ms
81,520 KB |
testcase_17 | AC | 215 ms
84,160 KB |
testcase_18 | AC | 208 ms
84,360 KB |
testcase_19 | AC | 210 ms
84,204 KB |
testcase_20 | AC | 212 ms
84,372 KB |
testcase_21 | AC | 207 ms
81,504 KB |
testcase_22 | AC | 205 ms
81,472 KB |
testcase_23 | AC | 205 ms
81,272 KB |
testcase_24 | AC | 232 ms
84,520 KB |
testcase_25 | AC | 234 ms
84,692 KB |
ソースコード
from collections import deque import bisect import math from decimal import Decimal import heapq import sys sys.setrecursionlimit(10**9) h,w = map(int,input().split()) sx,sy,ex,ey = map(int,input().split()) bb = [list(input()) for i in range(h)] b = [[1 for i in range(w+1)] for j in range(h+1)] for i in range(h): for j in range(w): b[i+1][j+1] = int(bb[i][j]) q = deque([]) d = [[1 for i in range(w+1)] for j in range(h+1)] d[sx][sy] = 0 q.append((sx,sy)) lis = [[1,0],[-1,0],[0,1],[0,-1]] while q: (x,y) = q.popleft() if x == ex and y == ey: print("YES") exit() # 1masu for xx,yy in lis: if 1 <= x + xx <= h and 1 <= y + yy <= w: if abs(b[x+xx][y+yy] - b[x][y]) <= 1: if d[x+xx][y+yy] == 1: d[x+xx][y+yy] = 0 q.append((x+xx,y+yy)) # 2masu for xx,yy in lis: if 1 <= x + 2*xx <= h and 1 <= y + 2*yy <= w: if b[x+xx][y+yy] <= b[x][y] and b[x+2*xx][y+2*yy] == b[x][y]: if d[x+2*xx][y+2*yy] == 1: d[x+2*xx][y+2*yy] = 0 q.append((x+2*xx,y+2*yy)) print("NO")