rhakdns120403
def bfs() :
global knight, target, m, l, c, k
queue = [[knight[0], knight[1]]]
while True :
q = queue
print(type(q[0]), type(q[1]), type(l[0][0]))
if q[0]+2 < m and q[1]+1 < m and l[q[0]+2][q[1]+1] != 1 :
queue.append([q[0]+2, q[1]+1])
l[q[0]+2][q[1]+1] = 1
c += 1
if l[q[0]+2][q[1]+1] == 2 :
break
if q[0]+2 < m and q[1]-1 >= 0 and l[q[0]+2][q[1]-1] != 1 :
queue.append([q[0]+2, q[1]-1])
l[q[0]+2][q[1]-1] = 1
c += 1
if l[q[0]+2][q[1]-1] == 2:
break
if q[1]+2 < m and q[0]+1 < m and l[q[0]+1][q[1]+2] != 1 :
queue.append([q[0]+1, q[1]+2])
l[q[0]+1][q[1]+2] = 1
c += 1
if l[q[0]+1][q[1]+2] == 2 :
break
if q[1]+2 < m and q[0]-1 >= 0 and l[q[0]-1][q[1]+2] != 1 :
queue.append([q[0]-1, q[1]+2])
l[q[0]-1][q[1]+2] = 1
c += 1
if l[q[0]-1][q[1]+2] == 2 :
break
if q[0]-2 >= 0 and q[1]+1 < m and l[q[0]-2][q[1]+1] != 1 :
queue.append([q[0]-2, q[1]+1])
l[q[0]-2][q[1]+1] = 1
c += 1
if l[q[0]-2][q[1]+1] == 2 :
break
if q[0]-2 >= 0 and q[1]-1 >= 0 and l[q[0]-2][q[1]-1] != 1 :
queue.append([[q[0]-2, q[1]-1]])
l[q[0]-2][q[1]-1] = 1
c += 1
if l[q[0]-2][q[1]-1] == 2 :
break
if q[1]-2 >= 0 and q[0]+1 < m and l[q[0]+1][q[1]-2] != 1 :
queue.append([[q[0]+1, q[1]-2]])
l[q[0]+1][q[1]-2] = 1
c += 1
if l[q[0]+1][q[1]-2] == 2 :
break
if q[0]-1 >= 0 and q[1]-2 >= 0 and l[q[0]-1][q[1]-2] != 1 :
queue.append([[q[0]-1, q[1]-2]])
l[q[0]-1][q[1]-2] = 1
c += 1
if l[q[0]-1][q[1]-2] == 2 :
break
k.append(c)
c = 0
k = []
m = int(input())
knight = list(map(int, input().split()))
target = list(map(int, input().split()))
l = [[0 for _ in range(m)] for _ in range(m)]
l[knight[0]-1][knight[1]-1] = 1
l[target[0]-1][target[1]-1] = 2
for i in range(m) :
for j in range(m) :
bfs()
if len(k) != 0 :
if k[0] <= k[1] :
k.pop(0)
else :
k.pop()
print(k[0])
3회 조회




