2024-08-21 13:05:04 +00:00
|
|
|
#include <algorithm>
|
2024-08-21 11:03:07 +00:00
|
|
|
#include <cctype>
|
2024-08-21 13:05:04 +00:00
|
|
|
#include <climits>
|
|
|
|
#include <cmath>
|
2024-08-21 11:03:07 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <iostream>
|
|
|
|
#include <ostream>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
const int MAX_N = 1e5+5;
|
|
|
|
|
|
|
|
struct Dir{
|
2024-08-21 13:05:04 +00:00
|
|
|
int x,y,dis1,dis2;
|
2024-08-21 11:03:07 +00:00
|
|
|
friend ostream& operator<<(ostream &os,Dir d){
|
|
|
|
os<<"Dir { x="<<d.x<<" ,y="<<d.y<<" } ";
|
|
|
|
return os;
|
|
|
|
}
|
2024-08-21 13:05:04 +00:00
|
|
|
}dirs[MAX_N];
|
2024-08-21 11:03:07 +00:00
|
|
|
int readInt();
|
2024-08-21 13:05:04 +00:00
|
|
|
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))
|
2024-08-21 11:03:07 +00:00
|
|
|
|
|
|
|
int main(){
|
2024-08-21 13:05:04 +00:00
|
|
|
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;
|
2024-08-21 11:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int readInt(){
|
|
|
|
int x=0,w=1;
|
|
|
|
char ch=0;
|
|
|
|
while(!isdigit(ch)){
|
|
|
|
if(ch=='-')w=-1;
|
|
|
|
ch=getchar();
|
|
|
|
}
|
|
|
|
while(isdigit(ch)){
|
|
|
|
x=x*10+(ch-'0');
|
|
|
|
ch=getchar();
|
|
|
|
}
|
|
|
|
return x*w;
|
|
|
|
}
|