Quoit Design

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

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

 
 //2017-08-09
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define mid ((l+r)>>1) using namespace std; const int N = ;
struct Point{
double x, y;
}P[N], p1[N], p2[N];
int n; bool cmp_x(Point a, Point b){
return a.x < b.x;
} bool cmp_y(Point a, Point b){
return a.y < b.y;
} double distance(Point *a, Point *b){
return sqrt((a->x - b->x)*(a->x - b->x) + (a->y - b->y)*(a->y - b->y));
} //分治,solve(l, r)表示区间[l, r]内的最近点对,solve(l, r) = min(solve(l, mid), solve(mid+1, r), 跨左右子区间的最近点对)
double solve(int l, int r){
if(l >= r)return ;
if(r - l == )return distance(&P[l], &P[r]);
if(r - l == )return min(distance(&P[l], &P[l+]), distance(&P[l+], &P[r]));
double ans = min(solve(l, mid), solve(mid+, r));
//暴力x坐标与mid的x坐标相差不超过当前最优解ans的点
int m = ;
for(int i = l; i <= r; i++){
if(fabs(P[mid].x - P[i].x) <= ans){
p1[m++] = P[i];
}
}
sort(p1, p1+m, cmp_y);
for(int i = ; i < m; i++){
for(int j = i+; j < m; j++){
if(p1[j].y - p1[i].y > ans)break;
ans = min(ans, distance(&p1[i], &p1[j]));
}
}
return ans;
} int main()
{
//freopen("dataIn.txt", "r", stdin);
while(scanf("%d", &n)!=EOF && n){
for(int i = ; i < n; i++)
scanf("%lf%lf", &P[i].x, &P[i].y);
sort(P, P+n, cmp_x);
printf("%.2lf\n", solve(, n-)/);
} return ;
}

HDU1007(最近点对)的更多相关文章

  1. Quoit Design(hdu1007)最近点对问题。模版哦!

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

  2. HDU1007最近点对(分治)

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 直接见代码吧.不过这个是N*logN*logN的 尽管如此,我怎么感觉我的比他们的还快??? #inclu ...

  3. (hdu1007)Quoit Design,求最近点对

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

  4. hdu1007 平面最近点对(暴力+双线程优化)

    突发奇想,用双线程似乎可以优化一些暴力 比如说平面最近点对这个题目,把点复制成2份 一份按照x排序,一份按照y排序 然后双线程暴力处理,一份处理x,一份处理y 如果数据利用x递减来卡,那么由于双线程, ...

  5. HDU-1007 Quoit Design 平面最近点对

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1007 简单裸题,测测模板,G++速度快了不少,应该是编译的时候对比C++优化了不少.. //STATU ...

  6. 最近点对HDU1007

    利用二分的方法来计算,应该是说利用分治的方法吧! 刚开始感觉时间会爆 后来发现嘎嘎居然没有 ,嗨自己算错了时间: #include <iostream> #include<cstdi ...

  7. 【hdu1007】最近点对

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 分治法的经典应用,复杂度可以证明为nlognlogn #include <iostream> ...

  8. ICP算法(Iterative Closest Point迭代最近点算法)

    标签: 图像匹配ICP算法机器视觉 2015-12-01 21:09 2217人阅读 评论(0) 收藏 举报 分类: Computer Vision(27) 版权声明:本文为博主原创文章,未经博主允许 ...

  9. Quoit Design---hdu1007(最近点对问题 分治法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1007 题意:给你n(2<=n<=10^6)个点的坐标,然后找到两个点使得他们之间的距离最小 ...

随机推荐

  1. python爬虫实践教学

    i春秋作家:Mochazz 一.前言 这篇文章之前是给新人培训时用的,大家觉的挺好理解的,所以就分享出来,与大家一起学习.如果你学过一些python,想用它做些什么又没有方向,不妨试试完成下面几个案例 ...

  2. InfluxDB配置文件详解

    全局配置 # 该选项用于上报influxdb的使用信息给InfluxData公司,默认值为false reporting-disabled = false # 备份恢复时使用,默认值为8088 bin ...

  3. [JavaScript] Nginx实现跨域设置

    假如跨域请求的接口为:http://xxx.cn/was5/web/search Nginx配置: 在conf/nginx.conf文件中 location / { root html; index ...

  4. TCP连接详解

    一. 连接过程示意图 二. 建立TCP连接 2.1 三次握手 第一次握手:建立连接.客户端发送连接请求报文段,将SYN置为1,Sequence Number为x:然后,客户端进入SYN_SEND状态, ...

  5. CentOS7安装MYSQL。

    参考这个文章(网页已存到本地):http://www.cnblogs.com/starof/p/4680083.html 安装完成后,本地登录MYSQL没有问题. 现在主要是在windows下用ora ...

  6. C#连接Access2013

    今天测试连接Access2013数据库,遇到错误,综合几个大神建议,解决了 我的系统是windows 2008 64位的,连接字符串如下: <connectionStrings> < ...

  7. Python之tkinter中的askyescancel窗口返回值

    if messagebox.askokcancel(title="确认取消",message="您确认注册该账号吗?"): messagebox.showinf ...

  8. Dell R730服务器 Raid5配置

    Dell R730服务器,有7块5t硬盘,默认做的RAID5.我们的目的是取其中6块硬盘做RAID5,留一块硬盘做热备. 一块SSD系统盘. 在这里,我具体解释一下 ①6块硬盘做成RAID5 ②6块硬 ...

  9. 阿里语音识别(语音转文字)java调用全程手把手详解-适合中小学生快速上手

    阿里语音识别服务java调用全程手把手详解-适合中小学生快速上手 阿里语音识别与百度语音识别的调用对比: 用例:1分30秒的录音文件    百度用时:3秒    阿里用时:30秒    识别准确率来看 ...

  10. 【转】谷歌三大核心技术(一)The Google File System中文版

      The Google File System中文版 译者:alex 摘要 我们设计并实现了Google GFS文件系统,一个面向大规模数据密集型应用的.可伸缩的分布式文件系统.GFS虽然运行在廉价 ...