当前位置: 首页> 房产> 政策 > 华为od统一考试B卷【AI面板识别】python实现

华为od统一考试B卷【AI面板识别】python实现

时间:2025/7/16 13:14:02来源:https://blog.csdn.net/weixin_43837522/article/details/141166855 浏览次数:0次

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

思路

在这里插入图片描述

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)))
关键字:华为od统一考试B卷【AI面板识别】python实现

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: