求问各位大佬,为什么这个答案只能90分?错在哪里呢?
from queue import Queue
def bfs(sx, sy):
queue = Queue()
queue.put((sx, sy, 0))
cnt = 0
vis[sx][sy] = 1
while queue.qsize():
xy = queue.get()
x1, y1, level = xy[0], xy[1], xy[2]
lst[x1][y1] = level
cnt += 1
for d in direction:
if -1 < x1+d[0] < n and -1 < y1+d[1] < m and not vis[x1+d[0]][y1+d[1]]:
vis[x1+d[0]][y1+d[1]] = 1
queue.put((x1+d[0], y1+d[1], level+1))
n, m, x, y = map(int, input().split())
lst = [[0]*m for _ in range(n)]
vis = [[0]*m for _ in range(n)]
direction = [(1, -2), (1, 2), (-1, -2), (-1, 2), (2, 1), (2, -1), (-2, 1), (-2, -1)]
bfs(x-1, y-1)
for i in range(n):
for j in range(m):
if i != x-1 and j != m-1 and not lst[i][j]:
lst[i][j] = -1
print(lst[i][j], end='')
if j != m-1:
print(' '*(6-len(str(lst[i][j]))), end='')
print()