http://acm.hdu.edu.cn/showproblem.php?pid=1007

Quoit Design

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 58813    Accepted Submission(s): 15582

Problem Description
Have
you ever played quoit in a playground? Quoit is a game in which flat
rings are pitched at some toys, with all the toys encircled awarded.
In
the field of Cyberground, the position of each toy is fixed, and the
ring is carefully designed so it can only encircle one toy at a time. On
the other hand, to make the game look more attractive, the ring is
designed to have the largest radius. Given a configuration of the field,
you are supposed to find the radius of such a ring.

Assume that
all the toys are points on a plane. A point is encircled by the ring if
the distance between the point and the center of the ring is strictly
less than the radius of the ring. If two toys are placed at the same
point, the radius of the ring is considered to be 0.

 
Input
The
input consists of several test cases. For each case, the first line
contains an integer N (2 <= N <= 100,000), the total number of
toys in the field. Then N lines follow, each contains a pair of (x, y)
which are the coordinates of a toy. The input is terminated by N = 0.
 
Output
For
each test case, print in one line the radius of the ring required by
the Cyberground manager, accurate up to 2 decimal places.
 
Sample Input
2
0 0
1 1
2
1 1
1 1
3
-1.5 0
0 0
0 1.5
0
 
Sample Output
0.71
0.00
0.75
 
Author
CHEN, Yue
 
Source
  
  给出n个点,找到一个最大半径的圆,满足这个圆每次最多只能覆盖一个点。输出这个最大圆的半径。显然这个最大半径就是最近公共点对的一半,二分找最近距离就好了。、

  1. #include<iostream>
  2. #include<cmath>
  3. #include<cstdio>
  4. #include<algorithm>
  5. #include<cstring>
  6. #include<vector>
  7. using namespace std;
  8. #define inf 0x3f3f3f3f
  9. struct Point
  10. {
  11. double x,y;
  12. }P[];
  13. inline bool cmpx(Point A,Point B){return A.x<B.x;}
  14. inline bool cmpy(Point A,Point B){return A.y<B.y;}
  15. double dis(Point A,Point B)
  16. {
  17. double dx=(A.x-B.x)*(A.x-B.x);
  18. double dy=(A.y-B.y)*(A.y-B.y);
  19. return sqrt(dx+dy);
  20. }
  21. double solve(int l,int r)
  22. {
  23. if(l==r) return inf;
  24. if(l+==r) return dis(P[l],P[r]);
  25. vector<Point>vp;
  26. int mid=(l+r)>>;
  27. double res=min(solve(l,mid),solve(mid+,r));
  28. for(int i=l;i<=r;++i)
  29. if(P[i].x>=P[mid].x-res&&P[i].x<=P[mid].x+res)
  30. vp.push_back(P[i]);
  31. sort(vp.begin(),vp.end(),cmpy);
  32. for(int i=;i<vp.size();++i){
  33. for(int j=;i+j<vp.size()&&j<;++j){
  34. if(res>dis(vp[i],vp[i+j]))
  35. res=dis(vp[i],vp[i+j]);
  36. }
  37. }
  38. return res;
  39. }
  40. int main()
  41. {
  42. int n;
  43. while(cin>>n&&n){
  44. for(int i=;i<=n;++i)
  45. scanf("%lf%lf",&P[i].x,&P[i].y);
  46. sort(P+,P++n,cmpx);
  47. printf("%.2f\n",solve(,n)/2.0);
  48. }
  49. return ;
  50. }

HDU-1007-最小公共点对的更多相关文章

  1. HDU 1007 Quoit Design(二分+浮点数精度控制)

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  2. 【HDU 1007】Quoit Design

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 最近欧式距离模板题. 用分治大法(分治的函数名用cdq纯属个人习惯_(:з」∠)_) 一开始狂M. 后来判 ...

  3. HDU 1533 最小费用最大流(模板)

    http://acm.hdu.edu.cn/showproblem.php?pid=1533 这道题直接用了模板 题意:要构建一个二分图,家对应人,连线的权值就是最短距离,求最小费用 要注意void ...

  4. HDU 3374 最小/大表示法+KMP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3374 题意:给定一个串s,该串有strlen(s)个循环同构串,要求输出字典序最小的同构串的下标,字典 ...

  5. HDU 2609 最小表示法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609 题意:给定n个循环链[串],问有多少个本质不同的链[串](如果一个循环链可以通过找一个起点使得和 ...

  6. HDU 4162 最小表示法

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4162 题意:给定一个只有0-7数字组成的串.现在要由原串构造出一个新串,新串的构造方法:相邻2个位置的数字 ...

  7. HDU 1007 Quoit Design(经典最近点对问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1007 Quoit Design Time Limit: 10000/5000 MS (Java/Oth ...

  8. hdu 4289(最小割)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4289 思路:求最小花费,最小割应用,将点权转化为边权,拆点,(i,i+n)之间连边,容量为在城市i的花 ...

  9. HDU 6214 最小割边

    双倍经验题:HDU 6214,3987 求最小割的最小边. 方案一: 首先跑最大流,这个时候割上都满载了,于是将满载的边 cap = 1,其他 inf ,再跑最大流,这个时候限定这个网络的关键边就是那 ...

  10. hdu 1498(最小点覆盖集)

    50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

随机推荐

  1. logging/re - 总结

    logging 模块 很多程序都有记录日志的需求 logging的日志可以分为 debug(), info(), warning(), error() and critical()5个级别 1.输出到 ...

  2. 详解JMeter函数和变量(转载)

    详解JMeter函数和变量(1) JMeter函数可以被认为是某种特殊的变量,它们可以被采样器或者其他测试元件所引用.函数调用的语法如下: ${__functionName(var1,var2,var ...

  3. 前端 CSS 边框

    border 边框 solid 实体的 red 边框什么颜色 <!DOCTYPE html> <html lang="en"> <head> & ...

  4. 海报工厂之(一)android 如何给图片添加水印和文字

    在Android中如何给图片添加水印,下面截取了部分核心代码,仅供参考: /**      * 获取图片缩小的图片      * @param src      * @return      */   ...

  5. 003-spring结合java类调用quartz

    一.利弊 针对001 中设置,不方便程序中动态添加任务,只能使用配置进行配置任务, 适用于已知固定时刻需要执行的任务. 针对002中设置,不方便结合调用spring注入的实体 使用于程序内部新增添的任 ...

  6. [StringUtil ] isEmpty VS isBlank

    昨天才意识到这两个的存在. Blank(空字符串 blank) StringUtils.isNoneBlank(null) = false StringUtils.isNoneBlank(null, ...

  7. 2 TensorFlow入门笔记之建造神经网络并将结果可视化

    ------------------------------------ 写在开头:此文参照莫烦python教程(墙裂推荐!!!) ---------------------------------- ...

  8. CodeForces - 86D Powerful array (莫队)

    题意:查询的是区间内每个数出现次数的平方×该数值的和. 分析:虽然是道莫队裸体,但是姿势不对就会超时.答案可能爆int,所以要开long long 存答案.一开始的维护操作,我先在res里减掉了a[p ...

  9. 关于myeclipse+tomcat+struct2的热部署问题

    今天满心欢喜的打开电脑来写程序,却不曾想到它竟然给我搞事情,前几天刚学的struct2热部署竟然不好用了.每次改java文件都要重新部署好麻烦,最后花了了好长时间才解决,必须在这里总结一下: (1)s ...

  10. 使用Vue.js初次真正项目开发-2018/07/14

    一.组件化 使用Vue.js进行开发,按照MVVM模式,围绕数据为核心,进行开发. 开发过程根据业务和功能组件化,组件化一方面让我们开发思路更加清晰,另一方面对于数据的处理和控制变得更加简单,毕竟一个 ...