给你n个点,求面积最大的凸多边形,使得这个凸多边形没有内点。
考虑求凸包的graham算法,需要找到左下角的点,再进行极角排序后按顺序扫点,所以先枚举左下角的点。
这个过程中,如果遇到内点,就需要把这个内点排除掉,而现在需要把在外的点排除掉。
因为不确定凸包的边界,需要dp处理,一开始是一个三角线的两条边作为边界,然后不断枚举可能的边界进行扩展,同时保证不能包含内点。
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include <set>
#include <queue>
#define ll long long
#define ld long double
#define lson l,m,rt<<1
#define pi acos(-1)
#define rson m+1,r,rt<<1|1
#define fo(i,l,r) for(int i = l;i <= r;i++)
#define fd(i,l,r) for(int i = r;i >= l;i--)
#define mem(x) memset(x,0,sizeof(x))
#define eps 3e-11
using namespace std;
const int maxn = ;
const ll inf = 1e9;
const ll mod = ;
ll read() {
ll x=,f=;
char ch=getchar();
while(!(ch>=''&&ch<='')) {
if(ch=='-')f=-;
ch=getchar();
};
while(ch>=''&&ch<='') {
x=x*+(ch-'');
ch=getchar();
};
return x*f;
}
int sgn(double x){
if(fabs(x)<eps)return ;
if(x<)return -;
return ;
}
struct Point{
int id;
double x,y;
Point(){
}
Point(double _x,double _y){
x=_x;
y=_y;
}
friend bool operator < (Point a,Point b) {
return sgn(a.x-b.x)==?sgn(a.y-b.y)<:a.x<b.x;
}
double operator ^ (const Point &b) const{
return x*b.y - y*b.x;
}
bool operator == (const Point &b) const{
return sgn(x-b.x)==&&sgn(y-b.y)==;
}
Point operator - (const Point &b) const{
return Point(x-b.x,y-b.y);
}
double distance(Point b){
return sqrt((x-b.x)*(x-b.x) + (y-b.y)*(y-b.y));
}
};
struct polygon{
int n;
Point p[maxn];
struct cmp{
Point p;
cmp(const Point &p0) {p=p0;}
bool operator()(const Point &aa,const Point &bb){
Point a=aa,b=bb;
int d=sgn((a-p)^(b-p));
if(d==){
return sgn(a.distance(p) - b.distance(p)) < ;
}
return d>;
}
};
void norm(Point t){
sort(p+,p++n,cmp(t));
}
int relationpoint(Point q){
int cnt = ;
fo(i,,n-){
int j = (i+)%n;
int k = sgn((q-p[j])^(p[i]-p[j]));
int u = sgn(p[i].y-q.y);
int v = sgn(p[j].y-q.y);
if(k>&&u<&&v>=)cnt++;
if(k<&&v<&&u>=)cnt--;
if(k==)return ;
}
return cnt != ;
}
}ps,pts,rec;
int n;
bool ok[maxn][maxn][maxn];
double dp[maxn][maxn],ans;
void gao(int st){
memset(dp,,sizeof(dp));
int m = n-st+;
pts.n=m;
fo(i,,m){
pts.p[i] = ps.p[st+i-];
}
pts.norm(pts.p[]);
fo(i,,m){
fo(j,i+,m){
if(!ok[pts.p[].id][pts.p[i].id][pts.p[j].id]){
dp[i][j] = ;
}else{
bool flag = true;
fo(k,,i-){
if(sgn((pts.p[k]-pts.p[])^(pts.p[i]-pts.p[]))==){
flag=false;
break;
}
}
if(flag)fo(k,,i-){
if(sgn((pts.p[i]-pts.p[k])^(pts.p[j]-pts.p[i]))>=){ dp[i][j] = max(dp[i][j],dp[k][i]);
}
}
dp[i][j] += ((pts.p[i]-pts.p[]) ^ (pts.p[j]-pts.p[]))/2.0;
}
ans=max(ans,dp[i][j]);
}
}
}
int main() {
int T=read();
while(T--){
ans=;
n=ps.n=read();
fo(i,,n){
ps.p[i] = Point(read(),read());
}
sort(ps.p+,ps.p++n);
fo(i,,n) ps.p[i].id=i;
fo(i,,n){
fo(j,i+,n){
fo(k,j+,n){
rec.n=;
rec.p[]=ps.p[i];rec.p[]=ps.p[j];rec.p[]=ps.p[k];
ok[k][i][j]=ok[k][j][i]=ok[j][i][k]=ok[j][k][i]=ok[i][k][j]=ok[i][j][k]=true;
if(sgn((rec.p[]-rec.p[])^(rec.p[]-rec.p[]))==)continue;
fo(t,,n){
if(t==i||t==j||t==k)continue;
if(rec.relationpoint(ps.p[t])==){
ok[k][i][j]=ok[k][j][i]=ok[j][i][k]=ok[j][k][i]=ok[i][k][j]=ok[i][j][k]=false;
break;
}
}
}
}
}
fo(i,,n){
gao(i);
}
printf("%.1f\n",ans);
}
return ;
}
 

hdu 6219 Empty Convex Polygons (凸包)的更多相关文章

  1. 2017ACM/ICPC亚洲区沈阳站 C Hdu-6219 Empty Convex Polygons 计算几何 最大空凸包

    题面 题意:给你一堆点,求一个最大面积的空凸包,里面没有点. 题解:红书板子,照抄完事,因为题目给的都是整点,所以最后答案一定是.5或者.0结尾,不用对答案多做处理 #include<bits/ ...

  2. hdu6219 Empty Convex Polygons (最大空凸包板子

    https://vjudge.net/contest/324256#problem/L 题意:给一堆点,求最大空凸包面积. 思路:枚举凸包左下角点O,dp找出以这个点为起始位置能构成的最大空凸包面积, ...

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

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

  4. HDU 1392 Surround the Trees(凸包*计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1392 这里介绍一种求凸包的算法:Graham.(相对于其它人的解释可能会有一些出入,但大体都属于这个算 ...

  5. HDU 4946 Area of Mushroom 凸包

    链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...

  6. HDU 4946 Area of Mushroom 凸包 第八次多校

    题目链接:hdu 4946 题意:一大神有N个学生,各个都是小神,大神有个二次元空间,每一个小神都有一个初始坐标,如今大神把这些空间分给徒弟们,规则是假设这个地方有一个人比谁都先到这,那么这个地方就是 ...

  7. Opencv Convex Hull (凸包)

    #include <iostream>#include <opencv2/opencv.hpp> using namespace std;using namespace cv; ...

  8. HDU - 1392 Surround the Trees (凸包)

    Surround the Trees:http://acm.hdu.edu.cn/showproblem.php?pid=1392 题意: 在给定点中找到凸包,计算这个凸包的周长. 思路: 这道题找出 ...

  9. HDU 1392 Surround the Trees (凸包周长)

    题目链接:HDU 1392 Problem Description There are a lot of trees in an area. A peasant wants to buy a rope ...

随机推荐

  1. 将div的内容生成清晰的PDF、高清PDF

    //需要引入html2canvas.js.jquery.js文件 html: <button type="button" class="btn btn-primar ...

  2. Day03-jS

    javaScript概述 什么是javaScript:javaScript是一种直译式脚本语言.直接解释执行的语言. 什么是脚本语言? . java源代码--->编译成.class文件 ---& ...

  3. 【抓包工具】使用Fiddler关于“由于目标计算机积极拒绝,无法连接。”的解决方案

    今天使用Fiddler的时候遇到下面这个问题:在地址栏想打开个一般处理程序,出现连接本机失败的提示,如下图: 而这在我没打开Fiddler的时候是显示正常的. 查看Fiddler,在嗅探 -> ...

  4. mongoose 开源http库(2) --HTTP服务示例

    要创建HTTP服务器,请按照以下格式: 通过调用mg_bind()或mg_bind_opt()创建侦听连接 调用mg_set_protocol_http_websocket()创建listening连 ...

  5. 三、Vue CLI-单页面

    一.单页面 代码如下: <template> <div class="header">{{title}}</div> </template ...

  6. mysql5.7使用gtid模式搭建主从复制架构

    一.架构 两台mysql服务器做一主一从,172.28.18.69(主) 172.28.18.78(从) 二.分别编译安装mysql5.7 1.下载mysql5.7.26源码包 [root@serve ...

  7. Binary Numbers AND Sum CodeForces - 1066E (前缀和)

    You are given two huge binary integer numbers aa and bb of lengths nn and mmrespectively. You will r ...

  8. CodeForces - 841D Leha and another game about graph

    给出一个连通图,并给每个点赋一个d值0或1或-1,要求选出一个边的集合,使得所有的点i要么d[i] == -1,要么 dgree[i] % 2 == d[i],dgree[i]代表i结点的度数. 考虑 ...

  9. [易学易懂系列|golang语言|零基础|快速入门|(四)]

    今天开始,我们来写代码. 学习一门语言,最快的方式就是写代码,做项目. 别的学习教程,都是hello world. 我们就来点不一样的吧.我们不一样!不一样!不一样! 首先,打开VSCODE.( 关于 ...

  10. 给oracle命令的参数赋值

    ''' <summary>    '''   给oracle命令的参数赋值    ''' </summary>    ''' <param name="cmd& ...