Quoit Design

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

Total Submission(s): 29694    Accepted Submission(s): 7788

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
 
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std; const double eps = 1e-7;
const double INF = 100000000000;
struct point{
double x , y;
point(double a = 0 , double b = 0){
x = a , y = b;
}
};
vector<point> P;
int N; bool cmp(point p1 , point p2){
if(p1.x == p2.x) return p1.y<p2.y;
return p1.x<p2.x;
} bool cmpy(point p1 , point p2){
return p1.y<p2.y;
} void initial(){
P.clear();
} void readcase(){
double x , y;
for(int i = 0; i < N; i++){
scanf("%lf%lf" , &x , &y);
P.push_back(point(x , y));
}
} double dis(point p1 , point p2){
return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));
} double fenzhi(int l , int r){
if(l == r) return INF;
if(r-l==1) return dis(P[l] , P[r]);
int mid = (l+r)/2;
double d = min(fenzhi(l,mid) , fenzhi(mid+1 , r));
int index = mid;
vector<point> tP;
for(int i = mid+1; i <= r; i++){
if(d-(P[i].x-P[mid].x) >= eps) tP.push_back(P[i]);
}
sort(tP.begin() , tP.end() , cmpy);
while(d-(P[mid].x-P[index].x) >= eps && index >= l){
for(int i = 0; i < tP.size(); i++){
if(tP[i].y-P[index].y-d>=eps) break;
d = min(d , dis(tP[i] , P[index]));
}
index--;
}
return d;
} void computing(){
sort(P.begin() , P.end() , cmp);
printf("%.2lf\n" , fenzhi(0 , N-1)/2);
} int main(){
while(scanf("%d" , &N) && N){
initial();
readcase();
computing();
}
return 0;
}

poj 1007 Quoit Design(分治)的更多相关文章

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

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

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

  5. hdu 1007 Quoit Design (最近点对问题)

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

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

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

  7. 最近点对问题 POJ 3714 Raid && HDOJ 1007 Quoit Design

    题意:有n个点,问其中某一对点的距离最小是多少 分析:分治法解决问题:先按照x坐标排序,求解(left, mid)和(mid+1, right)范围的最小值,然后类似区间合并,分离mid左右的点也求最 ...

  8. hdu 1007 Quoit Design(分治)

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

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

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

随机推荐

  1. network出错

    1.更改IP之后,执行service network restart时出现 shutting down interface eth0:Device state :3(disconnected)的问题时 ...

  2. Ionic实战七:Ionic 音乐以及社交页面

    Ionic 音乐以及社交页面,可以用于二次开发,也可以用于社交或者音乐app页面模板,但是不足的是图片没法预览.      

  3. Python爬虫个人记录(四)利用Python在豆瓣上写一篇日记

    涉及关键词:requests库 requests.post方法 cookies登陆 version 1.5(附录):使用post方法登陆豆瓣,成功! 缺点:无法获得登陆成功后的cookie,要使用js ...

  4. 一步一步写数据结构(BST-二叉排序树)

    二叉排序树的重要性不用多说,下面用c++实现二叉排序树的建立,插入,查找,修改,和删除.难点在于删除,其他几个相对比较简单. 以下是代码: #include<iostream> using ...

  5. 在静态方法中应用spring注入的类

    最近在一次项目的重构中,原项目需要在静态方法中调用service,现在需要更换框架,service需要自动注入,无法再静态方法中调用 解决思路: 创建一个当前类的静态变量,创建一个方法,使用@Post ...

  6. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之自签TLS证书及Etcd集群部署(二)

    0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.服务器设置 1.把每一 ...

  7. Django-url反向解析与csrf-token设置

    url反向解析 在使用Django 项目时,一个常见的需求是获得URL 的最终形式,以用于嵌入到生成的内容中(视图中和显示给用户的URL等)或者用于处理服务器端的导航(重定向等). 人们强烈希望不要硬 ...

  8. DHTML和HTML有什么区别?有什么不同

    DHTML和HTML有什么区别?有什么不同 首先Dynamic HTML是一种制作网页的方式,而不是一种网络技术(就像JavaScript和ActiveX):它也不是一个标记.一个插件或者是一个浏览器 ...

  9. github下载项目

  10. Git 入门使用

    Git是什么? Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制 ...