hdu 6219 Empty Convex Polygons (凸包)
#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 (凸包)的更多相关文章
- 2017ACM/ICPC亚洲区沈阳站 C Hdu-6219 Empty Convex Polygons 计算几何 最大空凸包
题面 题意:给你一堆点,求一个最大面积的空凸包,里面没有点. 题解:红书板子,照抄完事,因为题目给的都是整点,所以最后答案一定是.5或者.0结尾,不用对答案多做处理 #include<bits/ ...
- hdu6219 Empty Convex Polygons (最大空凸包板子
https://vjudge.net/contest/324256#problem/L 题意:给一堆点,求最大空凸包面积. 思路:枚举凸包左下角点O,dp找出以这个点为起始位置能构成的最大空凸包面积, ...
- HDU 6617 Enveloping Convex(凸包+半平面交+二分)
首先对于这m个点维护出一个凸包M,那么问题就变成了判断凸包P进行放大缩小能不能包含凸包M.(凸包P可以进行中心对称变换再进行放大缩小,见题意) 如何判断合适的相似比呢,我们可以用二分去放大缩小凸包P的 ...
- HDU 1392 Surround the Trees(凸包*计算几何)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1392 这里介绍一种求凸包的算法:Graham.(相对于其它人的解释可能会有一些出入,但大体都属于这个算 ...
- HDU 4946 Area of Mushroom 凸包
链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...
- HDU 4946 Area of Mushroom 凸包 第八次多校
题目链接:hdu 4946 题意:一大神有N个学生,各个都是小神,大神有个二次元空间,每一个小神都有一个初始坐标,如今大神把这些空间分给徒弟们,规则是假设这个地方有一个人比谁都先到这,那么这个地方就是 ...
- Opencv Convex Hull (凸包)
#include <iostream>#include <opencv2/opencv.hpp> using namespace std;using namespace cv; ...
- HDU - 1392 Surround the Trees (凸包)
Surround the Trees:http://acm.hdu.edu.cn/showproblem.php?pid=1392 题意: 在给定点中找到凸包,计算这个凸包的周长. 思路: 这道题找出 ...
- 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 ...
随机推荐
- vue elementui table组件内容换行
解决方案 tableData = [ { "name": "domain111", "metric": [ "平均耗时" ...
- handlebars杂记
1.{{{caption}}}三个花括号,可以解析 空格 变成 ‘空格’. 2.数据是posts:[{ }]数组时候,可以用{{posts.length}}取得其数组长度 3.handl ...
- iptables-save - 保存 IP Tables
总览 SYNOPSIS iptables-save [-c] [-t table] 描述 DESCRIPTION iptables-save 用来将 IP Table 转储为可以简单解析的格式,输出到 ...
- AT&T推出云5G网络开源工具Airship
导读 AT&T新推出的云5G网络依赖于一个名为“Airship”的开源供应工具,该工具在周一发布了第一个版本. AT&T负责网络云的副总裁Amy Wheelus告诉LightReadi ...
- Codeforces 984 扫雷check 欧几里得b进制分数有限小数判定 f函数最大连续子段
A /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a,b) ...
- robotframework 使用Chrome手机模拟器两种方法
Open Google Simulator1 ${device metrics}= Create Dictionary width=${360} height=${640} pixelRatio=${ ...
- Python之网络编程之concurrent.futures模块
需要注意一下不能无限的开进程,不能无限的开线程最常用的就是开进程池,开线程池.其中回调函数非常重要回调函数其实可以作为一种编程思想,谁好了谁就去掉 只要你用并发,就会有锁的问题,但是你不能一直去自己加 ...
- ks代码助解
代码实现: data_test_2 = {'gd':[1,1,1,1,1,1,0,0,0,0,0,0,0],'score':[1,2,0,2,2,7,4,5,4,0,4,18,np.nan]} dat ...
- scikit-plot
安装说明 安装Scikit-plot非常简单,直接用命令: pip install scikit-plot 即可完成安装. 仓库地址: https://github.com/reiinakano/sc ...
- python连接 MySQ 数据库
python 是目前比较流行的语言,所以学习一下 首先需要 安装MySQL-python驱动 下载地址:http://dev.mysql.com/downloads/connector/python/ ...