思路
n = int(input())class Light:def __init__(self, id, x1, y1, x2, y2):self.id = idself.x1 = x1self.y1 = y1self.x2 = x2self.y2 = y2self.height = y2 - y1def get_lights_info(n):lights = []for _ in range(n):id, x1, y1, x2, y2 = map(int, input().strip().split())lights.append(Light(id, x1, y1, x2, y2))return lightslights = get_lights_info(n)
lights.sort(key=lambda light: light.y1)def process_lights(lights):result = []processed = set()lights_copy = lights[:]while lights_copy:base_light = lights_copy[0]same_row_lights = [light for light in lights_copy if abs(light.y1 - base_light.y1) <= (base_light.height / 2)]same_row_lights.sort(key=lambda l: l.x1)for light in same_row_lights:if light.id not in processed:result.append(light.id)processed.add(light.id)lights_copy = [light for light in lights_copy if light.id not in processed]return resultresult = process_lights(lights)
print(" ".join(map(str, result)))