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

相关推荐
程序猿编码10 分钟前
不依赖 vLLM/llama.cpp:一套面向学习的 DeepSeek-R1 CUDA 推理实现
c++·学习·语言模型·llama·vllm·大模型推理
2601_9628857218 分钟前
如何用 Python 计算溃疡指数(Ulcer Index)?
开发语言·python
kiracrimson29 分钟前
string 容器:从 C 字符串到会自己扩容的类
开发语言·数据结构·c++·stl
程序猿编码33 分钟前
纯 C++ 手写 LLM 推理引擎:分页 KV 缓存、连续批、多卡张量并行全部内置
c++·深度学习·缓存·大模型推理·自动微分·模型推理
一条闲鱼_mytube40 分钟前
分布式 ID 生成方案:雪花算法与号段模式
分布式·算法·wpf
程序边界41 分钟前
顶刊级论文配图全流程:用 Python 复刻 Nature/Science 风格图表
开发语言·python
普通人642 分钟前
uniapp模版JS
开发语言·javascript·小程序·uni-app·1024程序员节
Msir_Modern1 小时前
Noita 元胞沙盒笔记
算法·unity·c#·游戏引擎·元胞自动机
G018_star sky♬1 小时前
nodeJS他是如何用JavaScript封装C++的呢
开发语言·javascript·c++
wyhwust1 小时前
程序设计基础--C语言输入输出单元测试
c语言·开发语言