版本比较
题解:P16000 [ICPC 2020 NAC] Hopscotch
正文
增加 3 行删除 3 行
125 行未改动全部展开12612712812913013013113213313445 行未改动1801811821831841841851861871885 行未改动19419519619719819819920020120211 行未改动125 行未改动全部展开 for j in range(len(next_pos)): dist = abs(r1 - next_r[j]) + abs(c1 - next_c[j]) new_cost = base_cost + dist if new_cost < next_costs[j]: next_costs[j] = new_cost next_costs[j] = new_cost costs = next_costs print(min(costs))
if __name__ == "__main__":45 行未改动 costs = [0.0] * len(positions[1]) for v in range(1, k): curr_pos = positions[v] next_pos = positions[v + 1]
INF = float('inf') next_costs = [INF] * len(next_pos) next_r = [p[0] for p in next_pos] next_c = [p[1] for p in next_pos]5 行未改动 dist = math.hypot(r1 - next_r[j], c1 - next_c[j]) new_cost = base_cost + dist if new_cost < next_costs[j]: next_costs[j] = new_cost
costs = next_costs print(f"{min(costs):.6f}")
if __name__ == "__main__":11 行未改动