結果
| 問題 |
No.424 立体迷路
|
| コンテスト | |
| ユーザー |
rocoder
|
| 提出日時 | 2017-08-04 12:29:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,248 bytes |
| コンパイル時間 | 141 ms |
| コンパイル使用メモリ | 13,056 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-10-11 20:46:11 |
| 合計ジャッジ時間 | 2,088 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 5 |
| other | RE * 21 |
ソースコード
#maze rabirynce
def ab(a1):
if a1<0:
a1*=-1
return a
h,w=(int(i) for i in input().split())
sx,sy,gx,gy=(int(i) for i in input().split())
b=[[int(i) for i in input().split()] for i in range(H)]
v=[[sx,sy]]
Nd=0
i=0
a=[0]*w*h
while Nd<1 and i<h*w+1:
j=0
v.append([])
while j<len(v[i]):
tx=v[i][j][0]
ty=v[i][j][1]
for k in range(2):
for l in range(2):
k+=2
l+=2
k=-1**k
l=-1**l
ux=tx+k
uy=ty+l
if ux>=0 and ux<w and uy>=0 and uy<h and a[ux][uy]==0 and ab(b[tx,ty]-b[ux,uy])==1:
a[ux][uy]=1
v[i+1].append([ux,uy])
for k in range(2):
for l in range(2):
k+=2
l+=2
k=-1**k
l=-1**l
k*=2
l*=2
ux=tx+k
uy=ty+l
if ux>=0 and ux<w and uy>=0 and uy<h and a[ux][uy]==0 and b[tx,ty]==b[ux,uy]:
a[ux][uy]=1
v[i+1].append([ux,uy])
j+=1
if v[i+1]==[]:
Nd=2
i+=1
if Nd==1:
p="YES"
else:
p="NO"
print(p)
rocoder