二分所能形成圆的最大距离,然后将每一条边都向内推进这个距离,最后所有边组合在一起判断时候存在内部点

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath> using namespace std;
#define N 105
#define ll long long
#define eps 1e-7 int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
} struct Point{
double x,y;
Point(double x= , double y=):x(x),y(y){}
}p[N] , poly[N]; typedef Point Vector; struct Line{
Point p;
Vector v;
double ang;
Line(){}
Line(Point p , Vector v):p(p),v(v){ang = atan2(v.y , v.x);}
bool operator<(const Line &m) const{
return dcmp(ang-m.ang)<;
}
}line[N]; Vector operator+(Vector a , Vector b){return Vector(a.x+b.x , a.y+b.y);}
Vector operator-(Vector a , Vector b){return Vector(a.x-b.x , a.y-b.y);}
Vector operator*(Vector a , double b){return Vector(a.x*b , a.y*b);}
Vector operator/(Vector a , double b){return Vector(a.x/b , a.y/b);} double Cross(Vector a , Vector b){return a.x*b.y-a.y*b.x;}
double Dot(Vector a , Vector b){return a.x*b.x+a.y*b.y;}
double Len(Vector a){return sqrt(Dot(a,a));} bool OnLeft(Line L , Point P)
{
return dcmp(Cross(L.v , P-L.p))>;
} Point GetIntersection(Line a , Line b)
{
Vector u = a.p-b.p;
double t = Cross(b.v , u)/Cross(a.v , b.v);
return a.p+a.v*t;
} Vector Normal(Vector a)
{
double l = Len(a);
return Vector(-a.y , a.x)/l;
} int HalfplaneIntersection(Line *L , int n , Point *poly)
{
sort(L , L+n);
int first , last;
Point *p = new Point[n];
Line *q = new Line[n];
q[first=last=] = L[];
for(int i= ; i<n ; i++){
while(first<last && !OnLeft(L[i] , p[last-])) last--;
while(first<last && !OnLeft(L[i] , p[first])) first++;
q[++last] = L[i];
if(fabs(Cross(q[last].v , q[last-].v))<eps){
last--;
if(OnLeft(q[last] , L[i].p)) q[last]=L[i];
}
if(first < last) p[last-] = GetIntersection(q[last-] , q[last]);
}
while(first<last && !OnLeft(q[first] , p[last-])) last--;
if(last-first<=) return ;
p[last] = GetIntersection(q[last] , q[first]);
int m=;
for(int i=first ; i<=last ; i++) poly[m++] = p[i];
return m;
} double calArea(Point *p , int n)
{
if(!n) return ;
double ret = ;
for(int i= ; i<n ; i++){
ret += Cross(p[i-]-p[],p[i]-p[]);
}
return ret/;
} double bin_search(Point *p , int n)
{
double l = , r = 1e8 , m;
Vector unit;
while(r-l>=eps)
{
m = (l+r)/;
for(int i= ; i<=n ; i++){
unit = Normal(p[i]-p[i-]);
line[i-] = Line(p[i-]+unit*m , p[i]-p[i-]);
}
if(HalfplaneIntersection(line , n , poly)) l=m;
else r=m;
}
return l;
} int main()
{
// freopen("in.txt" , "r" , stdin);
int n ;
while(scanf("%d" , &n) , n)
{
for(int i= ; i<n ; i++) scanf("%lf%lf" , &p[i].x , &p[i].y);
p[n] = p[];
printf("%.6f\n" , bin_search(p , n));
}
}

POJ 3525 半平面交+二分的更多相关文章

  1. poj 3525 半平面交求多边形内切圆最大半径【半平面交】+【二分】

    <题目链接> 题目大意:给出一个四面环海的凸多边形岛屿,求出这个岛屿中的点到海的最远距离. 解题分析: 仔细思考就会发现,其实题目其实就是让我们求该凸多边形内内切圆的最大半径是多少.但是, ...

  2. POJ 3525 /// 半平面交 模板

    题目大意: 给定n,接下来n行逆时针给定小岛的n个顶点 输出岛内离海最远的点与海的距离 半平面交模板题 将整个小岛视为由许多半平面围成 那么以相同的比例缩小这些半平面 一直到缩小到一个点时 那个点就是 ...

  3. poj 1755 半平面交+不等式

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6461   Accepted: 1643 Descrip ...

  4. poj 1279 半平面交核面积

    Art Gallery Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6668   Accepted: 2725 Descr ...

  5. POJ 3525 Most Distant Point from the Sea [半平面交 二分]

    Most Distant Point from the Sea Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5153   ...

  6. POJ 3525 Most Distant Point from the Sea (半平面交+二分)

    Most Distant Point from the Sea Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 3476   ...

  7. 简单几何(半平面交+二分) LA 3890 Most Distant Point from the Sea

    题目传送门 题意:凸多边形的小岛在海里,问岛上的点到海最远的距离. 分析:训练指南P279,二分答案,然后整个多边形往内部收缩,如果半平面交非空,那么这些点构成半平面,存在满足的点. /******* ...

  8. HDU 6617 Enveloping Convex(凸包+半平面交+二分)

    首先对于这m个点维护出一个凸包M,那么问题就变成了判断凸包P进行放大缩小能不能包含凸包M.(凸包P可以进行中心对称变换再进行放大缩小,见题意) 如何判断合适的相似比呢,我们可以用二分去放大缩小凸包P的 ...

  9. poj 3335 /poj 3130/ poj 1474 半平面交 判断核是否存在 / poj1279 半平面交 求核的面积

    /*************** poj 3335 点序顺时针 ***************/ #include <iostream> #include <cmath> #i ...

随机推荐

  1. redis web 客户端工具 redis-admin

    redis-admin是基于java的redis web客户端(redis client),以方便广大程序员使用redis为宗旨,集五种数据结构增删改查于一身. https://github.com/ ...

  2. 使用==比较String类型

    String类型的比较 public class StringDemo { public static void main(String[] args) { String s1 = "abc ...

  3. 2D客户端+微端技术总结

    本人于2013年9月23号加入一个页游项目组, 并作为项目组的客户端小组的主程, 带领一个4个人(峰值)的前端小组, 进行微端的开发.微端项目于2014年8月底大体完成, 历时11个月.9月份之后微端 ...

  4. js控制手机号码中间用星号代替

    $("#tel").html($("#tel").substring(0,3)+"****"+$("#tel").sub ...

  5. Ubuntu安装nodeJS

    安装环境 ubuntu12.04 64bit nodejs-v0.8.14.tar.gz Node.js是一个基于google v8+javascript的服务端编程框架.但是Node.js又不是js ...

  6. mac svn

    开启svn服务:sudo svnserve -d -r /Users/fuyi/svnserver/mycode/

  7. python 写入csv文件

    import csv   fieldnames = ['Column1', 'Column2', 'Column3', 'Column4'] rows = [{'Column1': '0', 'Col ...

  8. STL中vector的用法

    vector是标准模板库的一种容器,是可存放各种类型的动态数组. #include<iostream> #include<vector> using namespace std ...

  9. javaSE基础之基本细节注解

    1.  对于多行注释而言,不能进行嵌套注释.....! /* dada /* d adasdas */ */ 只是不被允许的.... 2.对于记事本编程......如果竹类是公有类,则必须保证类名和为 ...

  10. 理解模数转换器的噪声、ENOB和有效分辨率

    ADC的主要趋势之一是分辨率越来越高.这一趋势影响各种应用,包括工厂自动化.温度检测和数据采集.对更高分辨率的需求正促使设计者从传统的12位逐次逼近寄存器(SAR)ADC转至分辨率高达24位的Δ-ΣA ...