poj 1007 Quoit Design(分治)
Quoit Design
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 29694 Accepted Submission(s): 7788
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.
by N = 0.
2
0 0
1 1
2
1 1
1 1
3
-1.5 0
0 0
0 1.5
0
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(分治)的更多相关文章
- 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 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)Tot ...
- 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 ...
- 杭电OJ——1007 Quoit Design(最近点对问题)
Quoit Design Problem Description Have you ever played quoit in a playground? Quoit is a game in whic ...
- 最近点对问题 POJ 3714 Raid && HDOJ 1007 Quoit Design
题意:有n个点,问其中某一对点的距离最小是多少 分析:分治法解决问题:先按照x坐标排序,求解(left, mid)和(mid+1, right)范围的最小值,然后类似区间合并,分离mid左右的点也求最 ...
- 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 ...
随机推荐
- python 创建项目
项目骨架 nose 测试框架 Windows 10 配置 创建骨架项目目录 Windows 10 的 PowerShell mkdir projects cd projects/ mkdir skel ...
- Openstack-开发基础 stevedore学习
在给openstack-N版加路由的时候发现怎么都无法搞定,原来现在用这个模块来处理了 stevedore是用来实现动态加载代码的开源模块.它是在OpenStack中用来加载插件的公共模块.可以独立于 ...
- oslo.config
cfg Module来自于OpenStack中的重要的基础组件oslo.config,通过cfg Module可以用来通过命令行或者是配置文件来配置一些options, 对于每一个选项使用Opt类或者 ...
- Navicat Premium 激活码 序列号。破解版。
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha Navicat Premium 激活码 序列号.破解版.
- Codeforces Round #448 C. Square Subsets
题目链接 Codeforces Round #448 C. Square Subsets 题解 质因数 *质因数 = 平方数,问题转化成求异或方程组解的个数 求出答案就是\(2^{自由元-1}\) , ...
- [BZOJ5338][TJOI2018]xor(可持久化Trie)
可持久化Trie模板题. 建两种可持久化Trie,每个点两棵,一棵对DFS求前缀和,一棵对祖先求前缀和. 或者树剖,不好写多少还多个log. #include<cstdio> #inclu ...
- ZOJ 2969 Easy Task
E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...
- hdoj 1753 大明A+B 高精度/java
大明A+B Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- CF 277.5 B.BerSU Ball 二分图的最大匹配 模版题
题意:求二分图的最大匹配数量 模版如下: //二分图匹配(匈牙利算法的DFS实现) //初始化:g[][]两边顶点的划分情况 //建立g[i][j]表示i->j的有向边就可以了,是左边向右边的匹 ...
- Lucene——索引的创建、删除、修改
package cn.tz.lucene; import java.io.File; import java.util.ArrayList; import java.util.List; import ...