202009-1称检测点查询

简介: 202009-1称检测点查询

本题链接 称检测点查询

本博客给出本题截图

6.png

C++

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 210;
int n, X, Y;
struct Point
{
    int x, y, d;
    int id;
    bool operator< (const Point& t) const
    {
        if (d != t.d) return d < t.d;
        return id < t.id;
    }
}q[N];
int get_dist(int x1, int y1, int x2, int y2)
{
    int dx = x1 - x2;
    int dy = y1 - y2;
    return dx * dx + dy * dy;
}
int main()
{
    cin >> n >> X >> Y;
    for (int i = 0; i < n; i ++ )
    {
        int x, y;
        cin >> x >> y;
        q[i] = {x, y, get_dist(X, Y, x, y), i + 1};
    }
    sort(q, q + n);
    for (int i = 0; i < 3; i ++ ) cout << q[i].id << endl;
    return 0;
}

总结

水题,不解释

目录
相关文章
|
IDE 开发工具 iOS开发
Kotlin教程笔记(11) - 面向对象之抽象类与接口
本系列教程笔记详细讲解了Kotlin语法,适合深入学习。若需快速掌握Kotlin,建议查阅“简洁”系列教程。本文重点介绍了Kotlin中的抽象类与接口,包括接口的定义、实现、继承,以及抽象类的定义、构造器、方法实现等关键概念。
121 2
Qt 之 QDebug,QString
Qt 之 QDebug,QString
219 0
|
SQL 存储 安全
数据库视频第一章
数据库视频第一章
158 0
|
网络协议 安全 定位技术
网络编程概述、网络编程三要素、InetAddress类及端口和协议介绍
网络编程概述、网络编程三要素、InetAddress类及端口和协议介绍
203 0
LeetCode 2079. 给植物浇水(前缀和)
LeetCode 2079. 给植物浇水(前缀和)
341 0
|
Web App开发 开发工具 Android开发
Android Git 客户端
1、tortoisegit   Git下载地址: https://tortoisegit.org/download/   SVN下载地址: https://tortoisesvn.net/downloads.
1885 0
|
1天前
|
数据采集 人工智能 自然语言处理
3分钟采集134篇AI文章!深度解析如何通过云无影AgentBay实现25倍并发 + LlamaIndex智能推荐
结合阿里云无影 AgentBay 云端并发采集与 LlamaIndex 智能分析,3分钟高效抓取134篇 AI Agent 文章,实现 AI 推荐、智能问答与知识沉淀,打造从数据获取到价值提炼的完整闭环。
308 90