Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
79338 彭士宝 求元素在矩阵中的位置 Python3 Wrong Answer 37 MS 3784 KB 525 2024-07-03 21:12:55

Tests(1/4):


Code:

def find_element_position(n, m, matrix): for i in range(n): for j in range(n): if matrix[i][j] == m: return i + 1, j # 因为题目要求输出的行列索引从1开始 return -1 # 读取输入 n, m = map(int, input().split()) matrix = [] for _ in range(n): matrix.append(list(map(int, input().split()))) # 调用函数并打印输出 position = find_element_position(n, m, matrix) if position == -1: print(-1) else: print(position[0], position[1])


Run Info:

------Input------
3 2 1 4 7 2 5 8 3 6 9
------Answer-----
1 0
------Your output-----
2 0