三分 90 pts 求调
查看原帖
三分 90 pts 求调
641163
abensyl楼主2023/8/14 19:14

RT

// author: syl
// language: c++
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5+5;
pair<int,int> d[N];
int xa,ya,xb,yb;
int getdis(int a,int b,int x,int y) {
	return (a-x)*(a-x)+(b-y)*(b-y);
}
int f(int a,int n) {
	int res=0;
	for(int i=1;i<=n;++i) {
		if(getdis(xa,ya,d[i].first,d[i].second)<=a) continue;
		res=max(res,getdis(xb,yb,d[i].first,d[i].second));
	} return res+a;
}
int bbsearch(int l,int r,int n) {
	while(l<r-1) {
		int m1=l+r>>1,m2=m1+r>>1;
		if(f(m1,n)<f(m2,n)) r=m2;
		else l=m1;
	} return min(f(l,n),f(r,n));
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr),
	cout.tie(nullptr);
	cin>>xa>>ya>>xb>>yb;
	int n;
	cin>>n;
	for(int i=1;i<=n;++i) cin>>d[i].first>>d[i].second;
	cout<<bbsearch(0,1e15,n);
	return 0;
}
2023/8/14 19:14
加载中...