AI识别面板

#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

struct Light

{

int id;

int x;

int y;

int r;

Light(int id, int x, int y, int r) : id(id), x(x), y(y), r(r)

{

}

};

bool compareByY(const Light& a, const Light& b)

{

return a.y < b.y;

}

bool compareByX(const Light& a, const Light& b)

{

return a.x < b.x;

}

int main()

{

int n;

cin >> n;

vector<Light> lights;

for(int i = 0; i < n; i++)

{

int id;

int x1;

int y1;

int x2;

int y2;

cin >> id >> x1 >> y1 >> x2 >> y2;

int x = (x1 + x2) / 2;

int y = (y1 + y2) / 2;

int r = (x2 - x1) / 2;

lights.emplace_back(id, x, y, r);

}

sort(lights.begin(), lights.end(), compareByY);

for(int i = 0; i < n; i++)

{

cout << lightsi.id << " ";

}

cout << endl;

string result;

int rowStartIndex = 0;

for(int i = 1; i < n; i++)

{

if(lightsi.y - lightsrowStartIndex.y > lightsrowStartIndex.r)

{

sort(lights.begin() + rowStartIndex, lights.begin() + i - 1, compareByX);

for(int j = rowStartIndex; j < i; j++)

{

result += to_string(lightsj.id) + " ";

}

rowStartIndex = i;

}

}

sort(lights.begin() + rowStartIndex, lights.end(), compareByX);

for(int i = rowStartIndex; i < n; i++)

{

result += to_string(lightsi.id) + " ";

}

cout << result << endl;

return 0;

}

5

1 0 0 2 2

2 3 0 5 3

3 6 0 8 2

4 0 6 2 7

5 4 6 6 7

1 2 3 4 5

5

1 0 0 2 2

2 6 1 8 3

3 3 2 5 4

5 5 4 7 6

4 0 4 2 6

1 2 3 4 5

相关推荐
雨落在了我的手上9 分钟前
初始java(十七):常⽤⼯具类介绍
java·开发语言
手写码匠16 分钟前
华为云Flexus+DeepSeek征文|基于华为云Flexus X实例 + Dify + DeepSeek 构建企业级智能知识库问答系统实战
人工智能·深度学习·算法·aigc
凤凰院凶涛QAQ20 分钟前
《Java版数据结构 & 集合类剖析》集合框架的封装设计与顺序表:“从 Iterable 到 ArrayList:集合框架的‘职业树“
java·开发语言·数据结构
大菜菜小个子21 分钟前
偏特化(Partial Specialization)理解
c++
吴可可12332 分钟前
Win7上开发CAD2004自定义实体全解析
c++·算法
孟华苏34 分钟前
怎么快速排查内存泄漏问题
java·开发语言·python
YXXY31334 分钟前
二叉树中的深搜算法介绍
算法
zz345729811336 分钟前
C语言中字符串常量存储位置
c语言·开发语言·算法·青少年编程
noipp37 分钟前
推荐题目:洛谷 P16510 [GKS 2015 #C] gRanks
java·c语言·开发语言·c++·python·算法
flyinmind37 分钟前
Java环境与Android环境中使用QuickJS
java·开发语言·javascript·quickjs