This commit is contained in:
Zengtudor 2024-08-21 21:05:04 +08:00
parent 4ae38aa62f
commit b4037033dd

View File

@ -1,4 +1,7 @@
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <ostream>
@ -7,17 +10,41 @@ using namespace std;
const int MAX_N = 1e5+5;
struct Dir{
Dir(int x,int y):x(x),y(y){}
int x,y;
int x,y,dis1,dis2;
friend ostream& operator<<(ostream &os,Dir d){
os<<"Dir { x="<<d.x<<" ,y="<<d.y<<" } ";
return os;
}
};
}dirs[MAX_N];
int readInt();
int n;
int ans=INT_MAX;
int l1Max = INT_MIN;
#define DIFF_SQU(a,b)(((a).x-(b).x)*((a).x-(b).x)+((a).y-(b).y)*((a).y-(b).y))
int main(){
Dir l1,l2;
l1.x=readInt(),l1.y=readInt(),l2.x=readInt(),l2.y=readInt();
n=readInt();
for(int i=1;i<=n;i++){
auto &di = dirs[i];
di.x=readInt(),di.y=readInt();
// l1Max=max(l1Max,(di.x-l1.x)*(di.x-l1.x)+(di.y-l1.y)*(di.y-l1.y));
di.dis1 = DIFF_SQU(di, l1);
di.dis2 = DIFF_SQU(di,l2);
}
sort(dirs+1,dirs+n+1,[](Dir a,Dir b)->bool{
return a.dis1<b.dis1;
});
int r2=0;
int ans=dirs[n].dis1;
for(int i=n-1;i>=1;i--){
if(dirs[i+1].dis2>r2)r2=dirs[i+1].dis2; //将距离拦截器一更远的那个纳入拦截器2的射程
ans=min(ans,dirs[i].dis1+r2);
}
cout<<ans<<endl;
}
int readInt(){