Radar

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3684    Accepted Submission(s): 1398

Problem Description
N
cities of the Java Kingdom need to be covered by radars for being in a
state of war. Since the kingdom has M radar stations but only K
operators, we can at most operate K radars. All radars have the same
circular coverage with a radius of R. Our goal is to minimize R while
covering the entire city with no more than K radars.
 
Input
The
input consists of several test cases. The first line of the input
consists of an integer T, indicating the number of test cases. The first
line of each test case consists of 3 integers: N, M, K, representing
the number of cities, the number of radar stations and the number of
operators. Each of the following N lines consists of the coordinate of a
city.
Each of the last M lines consists of the coordinate of a radar station.

All coordinates are separated by one space.
Technical Specification

1. 1 ≤ T ≤ 20
2. 1 ≤ N, M ≤ 50
3. 1 ≤ K ≤ M
4. 0 ≤ X, Y ≤ 1000

 
Output
For each test case, output the radius on a single line, rounded to six fractional digits.
 
Sample Input
1
3 3 2
3 4
3 1
5 4
1 1
2 2
3 3
 
Sample Output
2.236068
  水题,主要是为了贴模板。
 #include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const double eps=1e-;
const int N=,M=;
struct Point{int x,y;}c[N],r[N];
double sqr(double x){return 1.0*x*x;}
double dis(Point a,Point b){return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));} void P(int x){
printf("%d\n",x);
} int T,n,m,k,col[M],row[M];
int U[M],D[M],L[M],R[M];
int H[N],C[N],vis[N],cnt;
struct DLX{
void Init(int n,int m){
for(int i=;i<=m;i++){
L[i]=i-;R[i]=i+;
C[i]=;U[i]=D[i]=i;
}L[]=m;R[m]=;cnt=m;
for(int i=;i<=n;i++)H[i]=;
}
void Link(int r,int c){
C[c]+=;++cnt;
U[D[c]]=cnt;U[cnt]=c;
D[cnt]=D[c];D[c]=cnt;
row[cnt]=r;col[cnt]=c; if(H[r]){
L[R[H[r]]]=cnt;L[cnt]=H[r];
R[cnt]=R[H[r]];R[H[r]]=cnt;
}
else H[r]=L[cnt]=R[cnt]=cnt;
}
void Delete(int x){
for(int i=D[x];i!=x;i=D[i])
L[R[i]]=L[i],R[L[i]]=R[i];
}
void Resume(int x){
for(int i=U[x];i!=x;i=U[i])
L[R[i]]=i,R[L[i]]=i;
}
int F(){
int ret=;
for(int c=R[];c;c=R[c])vis[c]=;
for(int c=R[];c;c=R[c]){
if(vis[c])continue;ret+=;
for(int i=D[c];i!=c;i=D[i])
for(int j=R[i];j!=i;j=R[j])
vis[col[j]]=;vis[c]=;
}
return ret;
}
bool Dance(int dep){
if(!R[])return dep<=k;
if(dep+F()>k)return false;
int p=;
for(int i=R[];i;i=R[i])
if(!p||C[i]<C[p])p=i;
for(int i=D[p];i!=p;i=D[i]){
Delete(i);
for(int j=R[i];j!=i;j=R[j])Delete(j);
if(Dance(dep+))return true;
for(int j=L[i];j!=i;j=L[j])Resume(j);
Resume(i);
}
return false;
} bool Check(double d){
Init(m,n);
for(int i=;i<=m;i++)
for(int j=;j<=n;j++)
if(d>=dis(r[i],c[j]))
Link(i,j);
return Dance();
}
}dlx; int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;i++)
scanf("%d%d",&c[i].x,&c[i].y);
for(int i=;i<=m;i++)
scanf("%d%d",&r[i].x,&r[i].y);
double l=,r=1e3;
while(r-l>=eps){
double mid=(l+r)/;
if(dlx.Check(mid))r=mid;
else l=mid;
}
printf("%.6f\n",l);
}
return ;
}

搜索(DLX重复覆盖模板):HDU 2295 Radar的更多相关文章

  1. DLX精确覆盖与重复覆盖模板题

    hihoCoder #1317 : 搜索四·跳舞链 原题地址:http://hihocoder.com/problemset/problem/1317 时间限制:10000ms 单点时限:1000ms ...

  2. HDU 2295.Radar (DLX重复覆盖)

    2分答案+DLX判断可行 不使用的估计函数的可重复覆盖的搜索树将十分庞大 #include <iostream> #include <cstring> #include < ...

  3. [ACM] HDU 2295 Radar (二分法+DLX 重复覆盖)

    Radar Problem Description N cities of the Java Kingdom need to be covered by radars for being in a s ...

  4. HDU 2295 Radar 重复覆盖 DLX

    题意: N个城市,M个雷达站,K个操作员,问雷达的半径至少为多大,才能覆盖所有城市.M个雷达中最多只能有K个同时工作. 思路: 二分雷达的半径,看每个雷达可以覆盖哪些城市,然后做重复覆盖,判断这个半径 ...

  5. HDU 2295 Radar (重复覆盖)

    Radar Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  6. HDU 2295 Radar (二分 + Dancing Links 重复覆盖模型 )

    以下转自 这里 : 最小支配集问题:二分枚举最小距离,判断可行性.可行性即重复覆盖模型,DLX解之. A*的启发函数: 对当前矩阵来说,选择一个未被控制的列,很明显该列最少需要1个行来控制,所以ans ...

  7. HDU 2295 Radar dancing links 重复覆盖

    就是dancing links 求最小支配集,重复覆盖 精确覆盖时:每次缓存数据的时候,既删除行又删除列(这里的删除列,只是删除表头) 重复覆盖的时候:只删除列,因为可以重复覆盖 然后重复覆盖有一个估 ...

  8. hdu 2295 dlx重复覆盖+二分答案

    题目大意: 有一堆雷达工作站,安放至多k个人在这些工作站中,找到一个最小的雷达监控半径可以使k个工作人所在的雷达工作站覆盖所有城市 二分半径的答案,每次利用dlx的重复覆盖来判断这个答案是否正确 #i ...

  9. HDU 5046 Airport【DLX重复覆盖】

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5046 题意: 给定n个城市的坐标,要在城市中建k个飞机场,使城市距离最近的飞机场的最长距离最小,求这 ...

随机推荐

  1. 04_过滤器Filter_02_Filter解决中文乱码问题

    [过滤器解决中文乱码问题实例] [工程截图] [web.xml] <?xml version="1.0" encoding="UTF-8"?> &l ...

  2. PAT_1026 程序运行时间

    问题描述: 要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间.这个时间单位是clock ti ...

  3. Flash Professional CS6 安装zxp插件

    说明 头两天因工作原因需要使用DragonBones,他的工作方式是的Flash Professional CS5.5以上的环境. DragonBones提供的是一个文件名为:xzp的文件,在Wind ...

  4. sql server 2008数据复制

    SQL Server 2008数据库复制是通过发布/订阅的机制进行多台服务器之间的数据同步,我们把它用于数据库的同步备份.这里的同步备份指的是备份服务器与主服务器进行实时数据同步,正常情况下只使用主数 ...

  5. SQL VIEW(视图)

    1,视图包含行和列,就像一个真实的表. 2,视图中的字段就是来自一个或多个数据库中的真实的表中的字段. 3,我们可以向视图添加 SQL 函数.WHERE 以及 JOIN 语句,我们也可以提交数据,就像 ...

  6. 『奇葩问题集锦』npm install 报错 node-pre-gyp ERR! node-pre-gyp -v v0.6.25

    gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you ...

  7. yii 缓存探究

    1.在配置文件中 //在权威指南上是'cache' 其实可以根据不同的缓存组件起不同的名称 //memcache缓存 'memcache' => array( 'class' => 'sy ...

  8. 用Python实现的一个简单的随机生成器

    朋友在ctr工作,苦于各种排期神马的,让我帮他整一个xxxx管理系统 里面在用户管理上面需要有一个批量从文件导入的功能,我肯定不能用汉字来作唯一性约束,于是想到了随机生成. 我首先想到的是直接用ite ...

  9. openssl Mac编译小记

    1. 下载openssl包 2. 解压 3. 打开控制台, 进入包目录, 执行 ./Configure darwin64-x86_64-cc 4. make 5. 得到 libcrypto.a lib ...

  10. wpf RadioButton控件的一个bug,onpropertychanged后会修改旧属性的值

    测试代码下载:http://files.cnblogs.com/djangochina/RadioButtonBug.zip 从上面列表选择不同的行,再设置下面不同的radiobutton看看结果 b ...