(中等) HDU 2295 , DLX+重复覆盖+二分。
Description
#include<iostream>
#include<cstring> using namespace std; const int MaxN=;
const int MaxM=;
const int MaxNode=MaxN*MaxM; int K;
int N,M; struct DLX
{
int D[MaxNode],U[MaxNode],L[MaxNode],R[MaxNode],col[MaxNode];
int H[MaxN],S[MaxM];
int n,m,size; void init(int _n,int _m)
{
n=_n;
m=_m; for(int i=;i<=m;++i)
{
D[i]=U[i]=i;
L[i]=i-;
R[i]=i+; S[i]=;
}
L[]=m;
R[m]=; size=m; for(int i=;i<=n;++i)
H[i]=-;
} void Link(int r,int c)
{
col[++size]=c;
++S[c]; U[size]=U[c];
D[size]=c;
D[U[c]]=size;
U[c]=size; if(H[r]==-)
H[r]=L[size]=R[size]=size;
else
{
L[size]=L[H[r]];
R[size]=H[r];
R[L[H[r]]]=size;
L[H[r]]=size;
}
} void remove(int c)
{
for(int i=D[c];i!=c;i=D[i])
{
R[L[i]]=R[i];
L[R[i]]=L[i];
}
} void resume(int c)
{
for(int i=U[c];i!=c;i=U[i])
R[L[i]]=L[R[i]]=i;
} bool vis[MaxM]; int getH()
{
int ret=; for(int c=R[];c!=;c=R[c])
vis[c]=; for(int c=R[];c!=;c=R[c])
if(vis[c])
{
++ret;
vis[c]=; for(int i=D[c];i!=c;i=D[i])
for(int j=R[i];j!=i;j=R[j])
vis[col[j]]=;
} return ret;
} bool Dance(int d)
{
if(d+getH()>K)
return ; if(R[]==)
{
if(d<=K)
return ;
return ;
} int c=R[]; for(int i=R[];i!=;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+))
return ; for(int j=L[i];j!=i;j=L[j])
resume(j); resume(i);
} return ;
}
}; DLX dlx;
int Rx[],Ry[],Cx[],Cy[]; void solve()
{
double L=,R=1001.0,Mid; while(R-L>0.0000001)
{
Mid=(L+R)/; dlx.init(M,N); for(int i=;i<=M;++i)
for(int j=;j<=N;++j)
if(Mid*Mid>=(Rx[i]-Cx[j])*(Rx[i]-Cx[j])+(Ry[i]-Cy[j])*(Ry[i]-Cy[j]))
dlx.Link(i,j); if(dlx.Dance())
R=Mid;
else
L=Mid;
} cout<<L<<endl;
} int main()
{
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(); int T;
cin>>T; while(T--)
{
cin>>N>>M>>K; for(int i=;i<=N;++i)
cin>>Cx[i]>>Cy[i]; for(int i=;i<=M;++i)
cin>>Rx[i]>>Ry[i]; solve();
} return ;
}
(中等) HDU 2295 , DLX+重复覆盖+二分。的更多相关文章
- hdu 2295 dlx重复覆盖+二分答案
题目大意: 有一堆雷达工作站,安放至多k个人在这些工作站中,找到一个最小的雷达监控半径可以使k个工作人所在的雷达工作站覆盖所有城市 二分半径的答案,每次利用dlx的重复覆盖来判断这个答案是否正确 #i ...
- (中等) HDU 3335 , DLX+重复覆盖。
Description As we know,the fzu AekdyCoin is famous of math,especially in the field of number theory. ...
- hdu 2295 Radar 重复覆盖+二分
题目链接 给m个雷达, n个城市, 以及每个城市的坐标, m个雷达里只能使用k个, 在k个雷达包围所有城市的前提下, 求最小半径. 先求出每个雷达到所有城市的距离, 然后二分半径, 如果距离小于二分的 ...
- HDU 2295 Radar 重复覆盖 DLX
题意: N个城市,M个雷达站,K个操作员,问雷达的半径至少为多大,才能覆盖所有城市.M个雷达中最多只能有K个同时工作. 思路: 二分雷达的半径,看每个雷达可以覆盖哪些城市,然后做重复覆盖,判断这个半径 ...
- hdu3656Fire station(DLX重复覆盖 + 二分)
题目请戳这里 题目大意:一个城市n个点,现在要建m个消防站,消防站建在给定的n个点中.求建m个消防站后,m个消防站要覆盖所有的n个点的覆盖半径最小. 题目分析:重复覆盖问题,DLX解决.不过要求覆盖半 ...
- hdu2295(重复覆盖+二分)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2295 题意::一个国家有n个城市,有m个地方可以建造雷达,最多可以建K个雷达(K>=1 & ...
- hdu 2295 DLX
思路:裸的DLX重复覆盖 #include<set> #include<cmath> #include<queue> #include<cstdio> ...
- HDU 2295.Radar (DLX重复覆盖)
2分答案+DLX判断可行 不使用的估计函数的可重复覆盖的搜索树将十分庞大 #include <iostream> #include <cstring> #include < ...
- [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 ...
随机推荐
- [maven] 新建项目一直提示loading archetype list
Maven's JRE is running out of memory. Under Build > Build Tools > Maven > Importing, set &q ...
- HTML+CSS Day06 超链接的样式与搭配
1.格式 a:link {} 普通的.未被访问的链接 a:visited {} 用户已访问的链接 a:hover {} 鼠标指针位于链接的上方 a:active{} 链接被点击的时刻 2.常 ...
- Ubuntu配置eclipse
1.安装jdk 去官网下载最新版jdk,目前是 jdk-8u45-linux-x64.tar.gz 创建Java的目标路径文件夹,这里我们放在/usr/lib/jvm下面.在终端下操作: sudo m ...
- NPAPI简介
原文出处:http://blog.csdn.net/wwwsq/article/details/8254911 NPAPI是电脑上大部分非ie浏览器都支持的一种浏览器扩展,类似ie的activex技术 ...
- python 第三方库下载
C:\Python27\Scripts 路径下: easy_install.exe: C:\Python27\Scripts>easy_install.exe pycrypto pip.exe: ...
- 编译hadoop2.4
摘自 http://www.aboutyun.com/thread-8130-1-1.html.http://www.dataguru.cn/forum.php?mod=viewthread& ...
- 【转】HBase技术介绍 转载自 http://www.searchtb.com/2011/01/understanding-hbase.html
HBase简介 HBase – Hadoop Database,是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群. HB ...
- JSP 语法/标签
┣1.declaration Declaration定义了JSP脚本语言使用的变量和函数,这类似于Java中定义全局变量,或可以把它想像成pascal编程语言中的单元文件的interface部分.声明 ...
- 未能加载文件或程序集 Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0 解决 亲测
项目打开winform程序做的某些窗体时报错: ************* 异常文本 ************** System.Reflection.TargetInvocationExceptio ...
- Chapter 1 First Sight——14
I parked in front of the first building, which had a small sign over the door reading front office. ...