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. python之web框架(2):了解WSGI接口

    python之web框架(2):了解WSGI接口 1.什么是wsgi接口: wsgi:Web Service Gateway Interface.它不是模块,而只是一种规范,方便web服务器和各种框架 ...

  2. 源码之Java集合

    No1: ArrayList的扩容策略是,新容量扩大为原来的1.5倍. ArrayList不是线性安全的,因为没有使用synchronized关键字,但是优点是效率提高了.与之相比,Vector是线性 ...

  3. odoo发送信息到微信公众平台、企业微信

    目录 odoo发送信息到微信 @(odoo client.message.send_text) odoo发送信息到微信 在odoo平台中进行项目开发的时候有时会用到跟其他平台对接发送信息. 这里我写一 ...

  4. 删除或修改eclipse中svn的账号密码

    由于eclipse没有自带的管理svn账号的功能,我也没有找到相关的插件,要是有朋友知道的话也可以跟我说下哦!以下是关于自己手动去删除eclipse 软件的 svn账号,以便切换项目的时候去更换svn ...

  5. UNP学习总结(一)

    本文主要为对UNP第五章部分内容的实验和总结. UNP第五章对一个echo服务器和客户端在各种连接状态下的表现做了详细的分析,包括了: 正常启动和终止: accept返回前连接中止: 服务器进程终止: ...

  6. iOS 9应用开发教程之ios9的视图

    iOS 9应用开发教程之ios9的视图 了解IOS9的视图 在iPhone或者iPad中,用户看到的和摸到的都是视图.视图是用户界面的重要组成元素.本节将主要讲解ios9视图的添加.删除以及位置和大小 ...

  7. BZOJ3611 HEOI2014大工程

    先建虚树,然后统计答案. 对于这个两点间最大值和最小值的操作我参考了hzwer的代码. 建虚树时注意判自环 By:大奕哥 #include<bits/stdc++.h> using nam ...

  8. 502 解决:[WARNING] fpm_children_bury

    查过网上的资源,基本都是认为是php线程打开文件句柄受限导致的错误.具体的解决的办法如下:   1.提升服务器的文件句柄打开打开 /etc/security/limits.conf : (增加) * ...

  9. 如何成为一名优秀的CTO(首席技术官)

    最近我发现很多开发人员都表示不知道如何规划职业生涯的下一个步骤.基于我们目前所处的科技泡沫现象,很多工程师都倾向于留在大型的成熟公司,或者要么a)去初创企业工作要么b)自己搞初创公司. 回顾我自己的职 ...

  10. 用Win32编写发送消息至Notepad++的程序

    这次利用Win32编程写一个发送"Win32 Assembly,My First SendMessage Program !" 每个程序要发送消息至另一个程序的时候,通常使用Sen ...