Commit 060005ce by BellCodeEditor

auto save

parent 41ec0f2c
Showing with 20 additions and 23 deletions
import turtle
def fang():
for i in range(4):
turtle.forward(100)
turtle.right(90)
turtle.penup()
turtle.goto(-100,100)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
fang()
turtle.end_fill()
turtle.goto(0,100)
fang()
turtle.goto(0,0)
turtle.begin_fill()
fang()
turtle.end_fill()
turtle.goto(-100,0)
fang()
turtle.hideturtle()
turtle.done()
\ No newline at end of file
n,m=map(int,input().split())
ls=[[int(i) for i in input().split()] for i in range(n)]
x1,y1,x2,y2=map(int,input().split())
vis=[[0 for i in range(m)] for i in range(n)]
vis[x1][y1]=1
aa=[]
aa.append([x1,y1,0])
fx=[(0,1),(1,0),(0,-1),(-1,0)]
while len(aa)>0:
x,y=aa[0][0],aa[0][1]
if x==x2 and y==y2:
print(aa[0][-1])
break
for i in fx:
xx=x+i[0]
yy=y+i[1]
if 0<=xx<n and 0<=yy<m and vis[xx][yy]==0 and ls[xx][yy]==0:
aa.append([xx,yy,aa[0][-1]+1])
vis[xx][yy]=1
aa.pop(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment