【题意】
【解题方法】
【AC 代码】
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const double eps = 1e-8;
const int maxnode = 3000;
const int maxm = 55;
const int maxn = 55;
int n,m,K;
struct DLX
{
int n,m,size;
int U[maxnode],D[maxnode],R[maxnode],L[maxnode],Row[maxnode],Col[maxnode];
int H[maxn],S[maxn];
int ands,ans[maxn];
void init(int _n,int _m)
{
n = _n;
m = _m;
for(int i = 0;i <= m;i++)
{
S[i] = 0;
U[i] = D[i] = i;
L[i] = i-1;
R[i] = i+1;
}
R[m] = 0; L[0] = m;
size = m;
for(int i = 1;i <= n;i++)
H[i] = -1;
}
void Link(int r,int c)
{
++S[Col[++size]=c];
Row[size] = r;
D[size] = D[c];
U[D[c]] = size;
U[size] = c;
D[c] = size;
if(H[r] < 0)H[r] = L[size] = R[size] = size;
else
{
R[size] = R[H[r]];
L[R[H[r]]] = size;
L[size] = H[r];
R[H[r]] = size;
}
}
void remove(int c)
{
for(int i = D[c];i != c;i = D[i])
L[R[i]] = L[i], R[L[i]] = R[i];
}
void resume(int c)
{
for(int i = U[c];i != c;i = U[i])
L[R[i]]=R[L[i]]=i;
}
bool v[maxnode];
int f()
{
int ret = 0;
for(int c = R[0];c != 0;c = R[c])v[c] = true;
for(int c = R[0];c != 0;c = R[c])
if(v[c])
{
ret++;
v[c] = false;
for(int i = D[c];i != c;i = D[i])
for(int j = R[i];j != i;j = R[j])
v[Col[j]] = false;
}
return ret;
}
bool Dance(int d)
{
if(d + f() > K)return false;
if(R[0] == 0)return d <= K;
int c = R[0];
for(int i = R[0];i != 0;i = R[i])
if(S[i] < S[c])
c = i;
for(int i = D[c];i != c;i = D[i])
{
remove(i);
for(int j = R[i];j != i;j = R[j])remove(j);
if(Dance(d+1))return true;
for(int j = L[i];j != i;j = L[j])resume(j);
resume(i);
}
return false;
}
};
DLX dlx;
struct Point{
int x,y;
}city[maxn],station[maxn];
double getdis(Point a,Point b){
return (double)((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
bool check(double r){
dlx.init(m,n);
double now=r*r;
for(int i=1; i<=m; i++){
for(int j=1; j<=n; j++){
if(getdis(station[i],city[j])<=now) dlx.Link(i,j);
}
}
return dlx.Dance(0);
}
int main()
{
int T;
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&n,&m,&K);
for(int i=1; i<=n; i++) scanf("%d%d",&city[i].x,&city[i].y);
for(int i=1; i<=m; i++) scanf("%d%d",&station[i].x,&station[i].y);
double l=0.0,r=2000;
while(r-l>=eps){
double mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid;
}
printf("%.6f\n",l);
}
return 0;
}