結果
問題 | No.424 立体迷路 |
ユーザー | 👑 Kazun |
提出日時 | 2021-02-11 21:00:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 878 bytes |
コンパイル時間 | 477 ms |
コンパイル使用メモリ | 86,540 KB |
実行使用メモリ | 77,628 KB |
最終ジャッジ日時 | 2023-09-25 10:40:16 |
合計ジャッジ時間 | 4,444 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
71,296 KB |
testcase_01 | AC | 95 ms
71,148 KB |
testcase_02 | AC | 92 ms
71,456 KB |
testcase_03 | AC | 93 ms
71,456 KB |
testcase_04 | AC | 94 ms
71,588 KB |
testcase_05 | AC | 93 ms
71,408 KB |
testcase_06 | AC | 94 ms
71,496 KB |
testcase_07 | AC | 93 ms
71,132 KB |
testcase_08 | AC | 93 ms
71,548 KB |
testcase_09 | AC | 92 ms
71,556 KB |
testcase_10 | AC | 94 ms
71,512 KB |
testcase_11 | AC | 92 ms
71,208 KB |
testcase_12 | AC | 92 ms
71,504 KB |
testcase_13 | AC | 93 ms
71,560 KB |
testcase_14 | AC | 91 ms
71,588 KB |
testcase_15 | AC | 93 ms
71,456 KB |
testcase_16 | AC | 90 ms
71,504 KB |
testcase_17 | AC | 131 ms
76,480 KB |
testcase_18 | AC | 98 ms
76,552 KB |
testcase_19 | AC | 99 ms
76,732 KB |
testcase_20 | AC | 96 ms
76,584 KB |
testcase_21 | AC | 89 ms
71,464 KB |
testcase_22 | AC | 90 ms
71,460 KB |
testcase_23 | AC | 90 ms
71,648 KB |
testcase_24 | AC | 116 ms
77,572 KB |
testcase_25 | AC | 112 ms
77,628 KB |
ソースコード
from collections import deque H,W=map(int,input().split()) sx,sy,tx,ty=map(int,input().split()) sx-=1;sy-=1;tx-=1;ty-=1 S=[] for _ in range(H): S.append(list(map(int,input()))) M=[(1,0),(-1,0),(0,1),(0,-1)] T=[[0]*W for _ in range(H)] T[sx][sy]=1 Q=deque([(sx,sy)]) while Q: x,y=Q.popleft() #隣のマスに移動 for a,b in M: if not (0<=x+a<H and 0<=y+b<W): continue if abs(S[x][y]-S[x+a][y+b])>=2: continue if T[x+a][y+b]==0: T[x+a][y+b]=1 Q.append((x+a,y+b)) #2個隣のマスに移動 for a,b in M: if not(0<=x+2*a<H and 0<=y+2*b<W): continue if S[x][y]==S[x+2*a][y+2*b] and S[x][y]>S[x+a][y+b]: if T[x+2*a][y+2*b]==0: T[x+2*a][y+2*b]=1 Q.append((x+2*a,y+2*b)) print("YES" if T[tx][ty] else "NO")