HDU 1007 Quoit Design
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
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 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.
each test case, print in one line the radius of the ring required by
the Cyberground manager, accurate up to 2 decimal places.
0 0
1 1
2
1 1
1 1
3
-1.5 0
0 0
0 1.5
0
0.00
0.75
Solution
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的更多相关文章
- HDU 1007 Quoit Design(经典最近点对问题)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1007 Quoit Design Time Limit: 10000/5000 MS (Java/Oth ...
- HDU 1007 Quoit Design(二分+浮点数精度控制)
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- hdu 1007 Quoit Design (最近点对问题)
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1007 Quoit Design【计算几何/分治/最近点对】
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 1007 Quoit Design 分治求最近点对
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1007 Quoit Design 平面内最近点对
http://acm.hdu.edu.cn/showproblem.php?pid=1007 上半年在人人上看到过这个题,当时就知道用分治但是没有仔细想... 今年多校又出了这个...于是学习了一下平 ...
- hdu 1007 Quoit Design(分治)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1007 题意:给出n个点求最短的两点间距离除以2. 题解:简单的分治. 其实分治就和二分很像二分的写df ...
- HDU 1007 Quoit Design(计算几何の最近点对)
Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat rings ...
- hdu 1007 Quoit Design (经典分治 求最近点对)
Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat rings ...
随机推荐
- Asp.net WebApi Put模式调用,“HTTP 错误 405.0 - Method Not Allowed”解决方法
IIS10.0在部署了WebAPI之后,默认是不支持Put模式调用的.需要按照下面方法启用. 步骤一:在IIS管理界面要支持Put模式的IIS站点,选择 "功能视图". 步骤二:选 ...
- jQuery学习笔记(四):attr()与prop()的区别
这一节针对attr()与prop()之间的区别进行学习. 先看看官方文档是如何解释两者之间功能差异的: attr() Get the value of an attribute for the fir ...
- IDEA 13 无法进入debug 模式解决方案
1.最近在idea中使用tomcat开发项目,像往常一样打开tomcat进行debug,但奇怪的事情出现了,项目根本不进断点.后查找原因,估计idea的加载参数方式是:先加载tomcat中设置的参数, ...
- SVN——配置和安装
SVN安装步骤: 所有安装文件下载地址:http://pan.baidu.com/s/1bocNTDl 一.安装01----VisualSVN-Server-3.4.2-x64.msi 文件 直接下一 ...
- js中的forEach
chrome和firefox支持数组的forEach,但不支持对象的forEach,IE啥都不支持 jquery中的$.each(ArrayOrObject,function)既可以遍历数组又可以遍历 ...
- Adobe Flash builder 4.6破解教程(以win764bit为例)
首先安装软件至默认路径: C:\Program Files(X86)\Adobe下 然后: 1.C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6 ...
- MVC 中的 ispostback
总之呢就是在MVC中试下 ispostback那种效果, 环境就是:登录验证loinger, if (Request.HttpMethod == "POST"){} 没理解透彻 源 ...
- zabbix 监控java程序
http://www.tuicool.com/articles/IRnM7f http://transcoder.baidu.com/from=1012852q/bd_page_type=1/ssid ...
- elasticsearch和hadoop集成,gateway.type hdfs设置
配置elasticsearch的存储路径为hdfs需要两步,安装插件 elasticsearch-hadoop,在联网的情况下在命令窗口运行:plugin -install elasticsearch ...
- 大素数测试 求因子 poj 1811
抄别人的 #include<stdio.h> #include<string.h> #include<algorithm> #include<stdlib.h ...