❄️ | 题目描述
给定(x,y)以及n个点的坐标
求出n个点中,距离到(x,y)最近的三个点的编号
✨ | 实现思路
用pair记录距离和节点编号id【pair默认对first进行排序】
排序后输出距离最小的前3个点
💓 | 具体代码
```cpp
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 220;
int n, x, y;
PII w[N];
int main()
{
cin >> n >> x >> y;
for (int i = 1; i <= n; i ++)
{
int a, b; cin >> a >> b;
w[i] = {(a - x) * (a - x) + (b - y) * (b - y), i};
}
sort(w + 1, w + 1 + n);
for (int i = 1; i <= 3; i ++)
cout << w[i].y << endl;
}
```