Quoit Design

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

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
 
Recommend
JGShining   |   We have carefully selected several similar problems for you:  1024 1016 3629 1044 1147 
 
 //1468MS    2288K    1378 B    G++
/* 题意;
给出n个点,求最近的两个点的距离的一般 最近点对:
要用到分治的思想做,是时间复杂度为O(nlgn),直接求会超时
最近点对问题在很多算法书和资料上都有讲到,主要思想是分治。 注意一点: 用C的 qsort排序一直TLE,表示有点无力.. */
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define N 100005
using namespace std;
struct node{
double x,y;
}p[N];
int a[N];
int n;
double cmpx(node a,node b)
{
return a.x<b.x;
}
double cmpy(int a,int b)
{
return p[a].y<p[b].y;
}
inline double Max(double a,double b)
{
return a>b?a:b;
}
inline double Min(double a,double b)
{
return a<b?a:b;
}
inline double Dis(node a,node b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double find(int l,int r)
{
if(l==r) return 0x7ffffff;
if(r==l+) return Dis(p[l],p[r]);
if(r==l+) return Min(Dis(p[l],p[r]),Min(Dis(p[l],p[l+]),Dis(p[l+],p[r])));
int mid=(l+r)>>;
double d=Min(find(l,mid),find(mid+,r));
int cnt=;
for(int i=l;i<=r;i++){
if(p[i].x>=p[mid].x-d && p[i].x<=p[mid].x+d)
a[cnt++]=i;
}
sort(a,a+cnt,cmpy);
for(int i=;i<cnt;i++){
for(int j=i+;j<cnt;j++){
if(p[a[j]].y-p[a[i]].y>=d) break;
d=Min(d,Dis(p[a[i]],p[a[j]]));
}
}
return d;
}
int main(void)
{
while(scanf("%d",&n)!=EOF)
{
if(n==) break;
for(int i=;i<n;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
sort(p,p+n,cmpx);
printf("%.2lf\n",find(,n-)/);
}
return ;
}

hdu 1007 Quoit Design (最近点对问题)的更多相关文章

  1. HDU 1007 Quoit Design最近点对( 分治法)

    题意: 给出平面上的n个点,问任意点对之间的最短距离是多少? 思路: 先将所有点按照x坐标排序,用二分法将n个点一分为二个部分,递归下去直到剩下两或一个点.对于一个部分,左右部分的答案分别都知道,那么 ...

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

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

  3. HDU 1007 Quoit Design【计算几何/分治/最近点对】

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

  4. hdu 1007 Quoit Design 分治求最近点对

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

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

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

  6. 杭电OJ——1007 Quoit Design(最近点对问题)

    Quoit Design Problem Description Have you ever played quoit in a playground? Quoit is a game in whic ...

  7. HDU 1007 Quoit Design 平面内最近点对

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 上半年在人人上看到过这个题,当时就知道用分治但是没有仔细想... 今年多校又出了这个...于是学习了一下平 ...

  8. HDU 1007 Quoit Design(计算几何の最近点对)

    Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat rings ...

  9. hdu 1007 Quoit Design(分治法求最近点对)

    大致题意:给N个点,求最近点对的距离 d :输出:r = d/2. // Time 2093 ms; Memory 1812 K #include<iostream> #include&l ...

随机推荐

  1. Mantle--国外程序员最常用的iOS模型&字典转换框架

    Mantle简介 Mantle是iOS和Mac平台下基于Objective-C编写的一个简单高效的模型层框架. Mantle能做什么 Mantle可以轻松把JSON数据.字典(Dictionary)和 ...

  2. 使用免费公开的api接口示例(iOS)

    做项目难免需要测试,要测试就需要一些接口,现在网上的很多接口都是需要收费的. 以下是目前找到的免费 JSON API免费接口 云聚数据 网吧数据 其中选取了一个百度百科的接口 百度接口 百度百科接口: ...

  3. jquery 表单事件

    .blur() 当元素失去焦点的时候触发事件. .blur(handler(eventObject)) handler(eventObject) 每当事件触发时候执行的函数. .blur([event ...

  4. 怎么退出jQuery的each函数

    返回 'false' 将停止循环 (就像在普通的循环中使用 'break').返回 'true' 跳至下一个循环(就像在普通的循环中使用'continue'). 以下举例如何退出 each 函数和退出 ...

  5. Ubuntu 18.04 配置

    Ubuntu 18.04 配置IP-静态(UB与其他linux os不同) sudo netplan generate sudo vim /etc/netplan/50-cloud-init.yaml ...

  6. 【PHP】nl2br转化输出input框的换行

    在input或者textarea框中输入的换行符保存到数据库是/n,如果直接输出到前端的话是不会有换行的,所以要用到nl2br转化 nl2br($test);

  7. Python元组,列表,字典,集合

    1.元组 元组是有序的,只有index和count两种方法,一看到元组,就提醒是不可更改的 names = ('wll', 'ly', 'jxx', 'syq') (1)index方法 print(n ...

  8. L2-032 彩虹瓶 (25 分)

    L2-032 彩虹瓶 (25 分)   彩虹瓶的制作过程(并不)是这样的:先把一大批空瓶铺放在装填场地上,然后按照一定的顺序将每种颜色的小球均匀撒到这批瓶子里. 假设彩虹瓶里要按顺序装 N 种颜色的小 ...

  9. 动态调试smali代码

    Android Killer对应用进行反编译为smali代码,看看Manifest文件中application标签里面是否有android:debuggable="true",没有 ...

  10. 6.bootstrap 将文本内容关联一个动作(手机端导航适配)&在超小尺寸下显示,屏幕变大后消失

    1.情景:这是出现在手机端导航适配的,点击文本MENU可以出现下拉的list 解决方法: 1.首先要想到,MENU只有两个状态,因此可以用checkbox实现 2.将MENU放在label标签里面,l ...