思路
n = int(input())
class Light:
def __init__(self, id, x1, y1, x2, y2):
self.id = id
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.height = y2 - y1
def 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 lights
lights = 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 result
result = process_lights(lights)
print(" ".join(map(str, result)))