这个代码自己看不出来有什么问题,测试一个都不通过def min_cost(N, matrix):directions = [(0, 1), (1, 0), (-1,0)]visited = set()start = (0, 0)end = (1, N-1)total_cost = matrix[0][0]i = 0while start != end:visited.add(start)tmp_cost = {}for direction in directions:new_x = start[0] + direction[0]new_y = start[1] + direction[1]if 0 <= new_x < 2 and 0 <= new_y < N and (new_x, new_y) not in visited:tmp_cost[(new_x, new_y)] = matrix[new_x][new_y]if i % 2 == 1:max_key = max(tmp_cost, key=tmp_cost.get)max_value = tmp_cost[max_key]total_cost += max_valuestart = max_keyi += 1else:min_key = min(tmp_cost, key=tmp_cost.get)min_value = tmp_cost[min_key]total_cost += min_valuestart = min_keyi += 1return total_cost