tj
2025-09-13 20:27:31
发布于:广东
4阅读
0回复
0点赞
#include<cstdio>
#include<algorithm>
using namespace std;
int x1,yl,x2,y2,n,ans,r1,r2;
struct node{
int x,y,d1;
}mis[100005];
int dis(int x,int y,int a,int b){
return (x-a)(x-a)+(y-b)(y-b);
}
bool cmp(node a,node b){
return a.d1>b.d1;
}
int main(){
int x, y;
scanf("%d%d%d%d%d", &x1,&yl,&x2,&y2,&n);
for(int i = 1; i <= n;i++)
{
scanf("%d%d", &x, &y);
mis[i].x = x;
mis[i].y = y;
mis[i].d1 = dis(x1,yl,mis[i].x,mis[i].y);
}
sort(mis+1, mis+n+1, cmp);
r1 = mis[1].d1;
ans = r1;
for(int i = 2; i <= n+1; i++){
r1 = mis[i].d1;
r2 = max(r2, dis(x2,y2,mis[i-1].x,mis[i-1].y));
ans=min(ans, r1+r2);
}
printf("%d", ans);
return 0;
}
这里空空如也
有帮助,赞一个