求n个点能组成的最大三角形,一发旋转卡壳模板题。。。

    #include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<sstream>
#include<vector>
#include<string>
#include<cstdio>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define FF(i, a, b) for(int i=a; i<b; i++)
#define FD(i, a, b) for(int i=a; i>=b; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
#define PB push_back
#define LL long long
#define eps 1e-10
#define debug puts("**debug**")
using namespace std; struct Point
{
double x, y;
Point(double x=0, double y=0) : x(x), y(y) {}
};
typedef Point Vector; Vector operator + (Vector a, Vector b) { return Vector(a.x+b.x, a.y+b.y) ; }
Vector operator - (Point a, Point b) { return Vector(a.x-b.x, a.y-b.y); }
Vector operator * (Vector a, double p) { return Vector(a.x*p, a.y*p); }
Vector operator / (Vector a, double p) { return Vector(a.x/p, a.y/p); } bool operator < (const Point& a, const Point& b)
{
return a.x < b.x || (a.x == b.x && a.y < b.y);
} int dcmp(double x)
{
if(fabs(x) < eps) return 0; return x < 0 ? -1 : 1;
}
bool operator == (const Point& a, const Point& b)
{
return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}
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 Length(Vector a) { return sqrt(Dot(a, a)); } int ConvexHull(Point* p, int n, Point* ch)
{
sort(p, p+n);
int m = 0;
REP(i, n)
{
while(m > 1 && Cross(ch[m-1]-ch[m-2], p[i]-ch[m-2]) <=0) m--;
ch[m++] = p[i];
}
int k = m;
FD(i, n-2, 0)
{
while(m > k && Cross(ch[m-1]-ch[m-2], p[i]-ch[m-2]) <= 0) m--;
ch[m++] = p[i];
}
if(n > 1) m--;
return m;
} double RC_Distance(Point* ch, int n) //凸包直径
{
int q = 1;
double ans = 0;
ch[n] = ch[0];
REP(p, n)
{
while(Cross(ch[q+1]-ch[p+1], ch[p]-ch[p+1]) > Cross(ch[q]-ch[p+1], ch[p]-ch[p+1])) q = (q+1)%n;
ans = max(ans, max(Length(ch[p]-ch[q]), Length(ch[p+1]-ch[q+1])));
}
return ans;
} double RC_Triangle(Point* res,int n)// 凸包最大内接三角形
{
if(n<3) return 0;
double ans=0, tmp;
res[n] = res[0];
int j, k;
REP(i, n)
{
j = (i+1)%n;
k = (j+1)%n;
while((j != k) && (k != i))
{
while(Cross(res[j] - res[i], res[k+1] - res[i]) > Cross(res[j] - res[i], res[k] - res[i])) k= (k+1)%n;
tmp = Cross(res[j] - res[i], res[k] - res[i]);if(tmp > ans) ans = tmp;
j = (j+1)%n;
}
}
return ans;
} Point read_point()
{
Point a;
scanf("%lf%lf", &a.x, &a.y);
return a;
} const int maxn = 1000010;
int n;
double x, y, w;
Point p[maxn], ch[maxn]; int main()
{
while(~scanf("%d", &n))
{
REP(i, n) p[i] = read_point();
int m = ConvexHull(p, n, ch);
double ans = RC_Triangle(ch, m);
printf("%.2f\n", ans/2);
}
return 0;
}

hdu 3934 Summer holiday(凸包最大内接三角形)的更多相关文章

  1. hdu 3934 Summer holiday (凸包+旋转卡壳)

    Problem - 3934 晚上为了演示给师弟看水平序的凸包是多么的好写,于是就随便找了一题凸包,25min居然1y掉了.. 代码如下: #include <cmath> #includ ...

  2. HDU 1827 Summer Holiday(强连通)

    HDU 1827 Summer Holiday 题目链接 题意:中文题 思路:强连通缩点,每一个点的权值为强连通中最小值,然后入度为0的点就是答案 代码: #include <cstdio> ...

  3. hdu 3934&&poj 2079 (凸包+旋转卡壳+求最大三角形面积)

    链接:http://poj.org/problem?id=2079 Triangle Time Limit: 3000MS   Memory Limit: 30000K Total Submissio ...

  4. hdu 1348 Wall(凸包模板题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 Wall Time Limit: 2000/1000 MS (Java/Others)    M ...

  5. POJ 1113 || HDU 1348: wall(凸包问题)

    传送门: POJ:点击打开链接 HDU:点击打开链接 以下是POJ上的题: Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissio ...

  6. HDU 6590 Code (判断凸包相交)

    2019 杭电多校 1 1013 题目链接:HDU 6590 比赛链接:2019 Multi-University Training Contest 1 Problem Description Aft ...

  7. hdu 2202 最大三角形 (凸包)

    最大三角形 Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  8. HDU 1348 Wall 【凸包】

    <题目链接> 题目大意: 给出二维坐标轴上 n 个点,这 n 个点构成了一个城堡,国王想建一堵墙,城墙与城堡之间的距离总不小于一个数 L ,求城墙的最小长度,答案四舍五入. 解题分析: 求 ...

  9. HDU 1827 Summer Holiday(tarjan求强连通分量+缩点构成新图+统计入度+一点贪心思)经典缩点入门题

    Summer Holiday Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

随机推荐

  1. 从setTimeout到浏览器线程机制

    看高性能javascipt 这本书时,看到这么一句话: Putting scripts at the top of the page in this way typically leads to a ...

  2. mysql解压版配置

    2. 解压MySQL压缩包 将以下载的MySQL压缩包解压到自定义目录下,我的解压目录是: "D:\Program Files\MySQL\mysql-5.6.13-win32" ...

  3. eclipsecpp从可执行程序员中导入源代码并调试

    如果寻找跨平台IDE及调试环境,那eclipse是最佳选择了,因为它有一项超强功能:可以从可执行程序员导入源代码并调试程序,这种特性是非常适合自定义MakeFile项目,不需要改变项目现有结果,即可自 ...

  4. [转]Geoserver全面了解

    From:http://www.cnblogs.com/ada-zheng/archive/2013/07/16/3192921.html Geoserver是一个功能齐全,遵循OGC开放标准的开源W ...

  5. kindeditor 下图片链接取消边框

    在项目中使用了 kindeditor,版本是4.1.10,在发布信息的时候,将图片设置成了超链接,在 IE8 或者其他个别浏览器下会自动的为图片加一个蓝色的边框,效果如下图: 这个蓝框可以通过修改信息 ...

  6. autolisp 列表 resbuf

    有以下 list : (1 2 3 (4 5 6) "Properties" (("id" . 3) ("name" . "hel ...

  7. Parallels destop8 无法创建bootcamp虚拟机

    创建基于Boot Camp的虚拟机时弹出“PRL_ERR_DISK_FILE_OPEN_ERROR (0x80021014)”错误提示,由于Mac系统权限错误或Boot Camp内Windows系统权 ...

  8. Android appcompat备案

    使用Eclipse创建Android项目,project多出appcompat_v7,此情况在ADT升级到22.6.x版本后出现,22.3.x前版本不存在.此项为了实现向下兼容sdk的功能. 点击项目 ...

  9. JQ调用后台方法

    首先,先在页面上创建一个asp按钮,添加点击事件,把要在前台调用的后台方法写在这个按钮的点击事件中: <span style="display:none;"><a ...

  10. CSS3阴影 box-shadow的使用

      text-shadow是给文本添加阴影效果,box-shadow是给元素块添加周边阴影效果.随着html5和CSS3的普及,这一特殊效果使用越来越普遍. 基本语法是{box-shadow:[ins ...