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. WPF ItemsControl 控件支持鼠标滚轮滑动

    此文章意在解决在WPF中ItemsControl类型的集合控件支持鼠标滚轮操作,并可控制滚动的速度. 第一步:给ItemsControl添加滚轮事件. this.listBox.AddHandler( ...

  2. js判断主流浏览器类型和版本号

    如今的互联网中,浏览器可以说是太多太多了,但是大部分都是换壳不换心,基本上主流的浏览器还是火狐,谷歌,IE,safrai这几种比较常见,所以在我们的开发中,有时候需要遇到判断用户正在使用什么浏览器以及 ...

  3. addLoadEvent函数

    首先是addLoadEvent函数的代码清单: function addLoadEvent(func){    var oldonload=window.onload;    if(typeof wi ...

  4. nvmw install 失败. 需修改"Msxml2.XMLHTTP"为"Msxml2.ServerXMLHTTP"

    准备在windows下学习nodejs. 下载了nvmw . 但没法安装node的任何版本. 都是报错如下: C:\Users\WXG>nvmw install v0.12.0 x86 Star ...

  5. 16_MyBatis中期小结

    [MyBatis是什么] MyBatis是一个持久层框架,Mybatis是一个不完全的ORM框架,SQL语句需要程序员自己去编写,但是MyBatis也有映射(输入参数映射.输出结果映射). MyBat ...

  6. Struts2配置文件_常量属性_独立测试分析

    <constant name="struts.devMode" value="true" /> 设置开发模式,可以了解详细信息,该属性指定视图标签默 ...

  7. O_NONBLOCK模式下写fifo的注意事项

    后台网络通信框架一般采用fifo来作为事件通知的机制:创建一个fifo,然后以非阻塞读和非阻塞写的方式打开fifo,然后把fd加到epoll里面,作为通知网络事件的fd. 在这里有个隐晦的问题容易被忽 ...

  8. JS对于字符串的切割截取

    对于字符串的切割截取平时所用可能不是特别多,而且分的比较细,所以自备自查.有备无患. 由于之前所有均在一个demo测试,若是哪里打错了,敬请谅解.一些其余属性找时间继续添加. 1.函数:split() ...

  9. 学习JS

    原型是Js中非常重要的概念,每个函数(在Js里面函数也是对象)都有一个叫prototype即原型)的属性,不过在一般情况下它的值都是null,但它他有一项非常重要的功能就是所以实例都会共享它里面的属性 ...

  10. 如何解决PHP中文乱码问题

    如何解决PHP中文乱码问题 一.解决HTML中中文乱码问题方法    1.在head标签里面加入UTF8编码(国际化编码):UTF-8是没有国家的编码,也就是独立于任何一种语言,任何语言都可以使用的. ...