本题链接:202009-1 称检测点查询
本博客给出本题截图:
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;
}
总结
水题,不解释