传送门

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

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

Solution

裸的平面最近点对,但要注意题目要求的是最大套圈的半径(radius),而所求出的最近点对间的距离相当于最大套圈的直径(diameter)。

Implementation

#include <bits/stdc++.h>
#define X first
#define Y second
#define INF 1e9
#define N 1<<17
using namespace std; typedef pair<double, double> P; P a[N]; bool compare_y(const P &a, const P &b){
return a.Y<b.Y;
}
//radius & diameter
double closest_pair(P *a, int n){
if(n<) return INF;
int m=n>>;
double x=a[m].X, d=min(closest_pair(a, m), closest_pair(a+m, n-m));
inplace_merge(a, a+m, a+n, compare_y); vector<P> b;
for(int i=; i<n; i++){
if(fabs(a[i].X-x)>=d) continue;
for(auto p=b.rbegin(); p!=b.rend(); p++){
double dx=a[i].X-p->X, dy=a[i].Y-p->Y;
if(dy>=d) break;
d=min(d, sqrt(dx*dx+dy*dy));
}
b.push_back(a[i]);
}
return d;
} int main(){
for(int n; cin>>n, n; ){
for(int i=; i<n; i++)
scanf("%lf%lf", &a[i].X, &a[i].Y);
sort(a, a+n);
printf("%.2f\n", closest_pair(a, n)/);
}
}

HDU 1007 Quoit Design的更多相关文章

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

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

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

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

  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)Tot ...

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

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

  7. hdu 1007 Quoit Design(分治)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1007 题意:给出n个点求最短的两点间距离除以2. 题解:简单的分治. 其实分治就和二分很像二分的写df ...

  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 (经典分治 求最近点对)

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

随机推荐

  1. Ubuntu环境下安装TinyOS系统

    1.输入下面命令会弹出source list窗口   1 sudo gedit /etc.apt/sources.list 在尾部添加以下地址:   1 2 deb http://tinyos.sta ...

  2. U-boot与linux的关系

    基本上没有啥关系,U-boot的话你也知道,说白了就像是Dos工具箱,本身算是个精简的Linux系统了,主要是负责硬件的初始化和引导,本身带有一些工具,作为引导程序,常作为嵌入式设备的引导.当真正的系 ...

  3. 纯手工打造漂亮的垂直时间轴,使用最简单的HTML+CSS+JQUERY完成100个版本更新记录的华丽转身!

    前言 FineUI控件库发展至今已经有 5 个年头,目前论坛注册的QQ会员 5000 多人,捐赠用户 500 多人(捐赠用户转化率达到10%以上,在国内开源领域相信这是一个梦幻数字!也足以证明Fine ...

  4. VS Code First使用Mysql数据库详解

    最近电脑出毛病了,自己装显卡驱动给装死了开不了机,自己研究了两天也没解决,只有去修电脑的找专业人员,说起来惭愧,虽然自己是搞计算机的可电脑自己重装系统都还搞不定.重装系统又清理灰尘花了50大洋,现在用 ...

  5. SQLite剖析之体系结构

    1.通过官方的SQLite架构文档,理清大体的系统层次:Architecture of SQLite 2.阅读SQLite Documentation中Technical/Design Documen ...

  6. [BZOJ3696][FJSC2014]化合物(异或规则下的母函数)

    题目:http://hzwer.com/3708.html 分析: 类似树分治思想,设f[x][i]表示以x为根的子树的所有点中,与x的距离为i的点有多少个,这个可以预处理出来 然后我们考虑每颗子树对 ...

  7. HIbernate的基本包——八个,详细条目

    antlr-2.7.6commons-collections-3.1dom4j-1.6.1hibernate3javassist-3.9.0.GAjta-1.1slf4j-api-1.5.8slf4j ...

  8. PHP Apache 配置伪静态

    1.首先是开启rewrite_module(如何开启,百度搜索) 2.创建.htaccess文件(如何创建,百度搜索) 3.在.htaccess文件中打开重写服务:RewriteEngine On 4 ...

  9. zabbix 用 LLD 完全自动化监控 Oracle

    文章转载自:http://mp.weixin.qq.com/s?__biz=MzA3MzYwNjQ3NA==&mid=2651296856&idx=1&sn=2bdf78071 ...

  10. Dubbo系列(1)_背景介绍和基本情况

    一.本文目的         主要介绍Dubbo的产生背景和需要解决的问题 二.产生背景         随着大数据量.高并发的互联网应用越来越多,单机系统已经无法满足系统的需要.通过SOA搭建一个分 ...