http://acm.hdu.edu.cn/showproblem.php?pid=2295
DLX重复覆盖+二分
# include <math.h>
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <algorithm>
# include <iostream>
# include <string>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <vector>
# include <cstring>
# include <list>
# include <ctime>
# define For(i,a) for((i)=0;i<(a);(i)++)
# define MAX(x,y) ((x)>(y)? (x):(y))
# define MIN(x,y) ((x)<(y)? (x):(y))
# define MEM(a) (memset((a),0,sizeof(a)))
# define MEME(a) (memset((a),-1,sizeof(a)))
# define MEMX(a) (memset((a),0x7f,sizeof(a)))
using namespace std;
typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ;
#define N 2550
#define ep 1e-6
int R[N],L[N],U[N],D[N];
int H[55],S[55],C[N];
int head,size;
struct node
{
int x,y;
}a[55],b[55];
double dis[N],c[55][55];
double cal(node a,node b)
{
return sqrt((double)((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)));
}
void build(int r,int c)
{
S[c]++;C[size]=c;
U[size]=U[c]; D[U[c]]=size;
D[size]=c; U[c]=size;
if(H[r]==-1) H[r]=R[size]=L[size]=size;
else
{
L[size]=L[H[r]]; R[L[H[r]]]=size;
R[size]=H[r]; L[H[r]]=size;
}
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])
{
R[L[i]]=i;
L[R[i]]=i;
}
}
int h()
{
int i,j,k,ret=0;
char vis[55];
MEM(vis);
for(i=R[head];i!=head;i=R[i])
{
if(!vis[i])
{
ret++;vis[i]=1;
for(j=D[i];j!=i;j=D[j])
for(k=R[j];k!=j;k=R[k])
vis[C[k]]=1;
}
}
return ret;
}
bool dfs(int dep,int K)
{
int i,j,min,c;
if(R[head]==head)
return true;
if(dep+h()>K)
return false;
for(i=R[head],min=N;i!=head;i=R[i])
if(S[i]<min)
{
min=S[i]; c=i;
}
remove(c);
L[R[c]]=L[c];R[L[c]]=R[c];
for(i=D[c];i!=c;i=D[i])
{
L[R[i]]=i;R[L[i]]=i;
for(j=R[i];j!=i;j=R[j])
remove(j);
if(dfs(dep+1,K)==true)
return true;
for(j=L[i];j!=i;j=L[j])
resume(j);
L[R[i]]=L[i];R[L[i]]=R[i];
}
L[R[c]]=c;R[L[c]]=c;
resume(c);
return false;
}
int main()
{
int t,i,j,k,r;
int n,m,K;
double ans;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&K);
for(i=0;i<n;i++)
scanf("%d%d",&a[i].x,&a[i].y);
for(i=0;i<m;i++)
scanf("%d%d",&b[i].x,&b[i].y);
k=0;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
dis[k++]=c[i][j]=cal(b[i],a[j]);
sort(dis,dis+k);
for(r=0,i=0;i<k;i++)
if(i==0||dis[i]!=dis[i-1])
dis[r++]=dis[i];
int left=0,right=r-1;
while(left<=right)
{
int mid=(left+right)>>1;
for(i=0;i<=n;i++)
{
R[i]=i+1;L[i]=i-1;
U[i]=i; D[i]=i;
S[i]=0;
}
R[n]=0;L[0]=n;
MEME(H);
head=0;size=n+1;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(c[i][j]<dis[mid]+ep)
build(i,j+1);
if(dfs(0,K)==true)
{
ans=dis[mid];
right=mid-1;
}
else
left=mid+1;
}
printf("%.6lf\n",ans);
}
}