代码矩阵上的运行时错误

2024-09-30 18:26:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图解决263A-beautifuly Matrix的问题,但出现了运行时错误

Here is the description

我的代码是:

import numpy as np

matrix = []
for i in range(5):
      matrix.append(list(map(int, input().split())))

arr = np.array(matrix)
loc =  list(np.argwhere(arr == 1)[0])

x1, y1, x2, y2 = loc[0], loc[1], 2, 2

print(abs(x1-x2)+abs(y1-y2)) # Manhattan distance

感谢您的帮助或指点


Tags: hereis错误npabsmatrixloclist
1条回答
网友
1楼 · 发布于 2024-09-30 18:26:16

运行时错误是由于使用了numpy库造成的。 我不确定,但是你不能在codeforces中使用这种库。 尝试在不使用此库的情况下回答此问题

如果你被卡住了,试着读社论

相关问题 更多 >