问题描述
解题思路
硬解法。
详细代码
#include<cstdio>
#include<algorithm>
using namespace std;
struct dis{
int num;//检测点编号
int x;
int y;
int distance;//与市民的距离
}a[201];
bool cmp(dis b,dis c)
{
if(b.distance!=c.distance )return b.distance<c.distance;
else return b.num<c.num;
}
int main()
{
int n,X,Y;
scanf("%d%d%d",&n,&X,&Y);
for(int i=1;i<=n;i++)
{
a[i].num=i;
scanf("%d%d",&a[i].x,&a[i].y);
a[i].distance=(X-a[i].x)*(X-a[i].x)+(Y-a[i].y)*(Y-a[i].y);
}
sort(a,a+n,cmp);
for(int i=1;i<=3;i++)
{
printf("%d\n",a[i].num);
}
return 0;
}