P2498 [SDOI2012]拯救小云公主
很直白的题
类似于NOIP2017奶酪
#define eps 1e-2
const int N = 3005;
int n,X,Y,dis[N][N]; bool vis[N];
struct node{int x,y;}pos[N];
inline double Pow(double x){return x*x;}
inline double diss(int i,int j){
return Pow(pos[i].x - pos[j].x) + Pow(pos[i].y - pos[j].y);
}
queue<int>q;
bool can(int d,double r){return Pow(r)*4 > d;}
bool bfs(double r){
memset(vis,false,sizeof(vis));
while(q.size()) q.pop();
for(int i = 1;i <= n;++i)
if(pos[i].x < r || Y -pos[i].y < r) q.push(i),vis[i] = 1;
while(q.size()){
int p = q.front(); q.pop();
if(X - pos[p].x < r || pos[p].y < r) return 0;
for(int i = 1;i <= n;++i)
if(!vis[i] && can(dis[p][i],r))
vis[i] = 1, q.push(i);
}
return true;
}
int main(){
n = read(); X = read() - 1; Y = read() - 1;
for(int i = 1;i <= n;++i)
pos[i].x = read() - 1,pos[i].y = read() - 1;
for(int i = 1;i <= n;++i)
for(int j = 1;j < i;++j)
dis[i][j] = dis[j][i] = diss(i,j);
double L = 0,R = min(X,Y),mid;
while(fabs(L - R) > eps){
double mid = (L + R)/2;
if(bfs(mid)) L = mid;
else R = mid;
}
printf("%.2f",L);
}