bzoj 1069
最开始想到的是枚举3个点,另一个点用卡壳的思想,但实际上可以只枚举两个点(对角线上的两个点),其余两个点用卡壳。
/**************************************************************
Problem: 1069
User: idy002
Language: C++
Result: Accepted
Time:232 ms
Memory:880 kb
****************************************************************/ #include <cstdio>
#include <cmath>
#include <algorithm>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define eps 1e-10
#define N 2010
using namespace std; int sg( double x ) { return (x>-eps)-(x<eps); }
struct Vector {
double x, y;
Vector(){}
Vector( double x, double y ):x(x),y(y){}
Vector operator+( const Vector & b ) const { return Vector(x+b.x,y+b.y); }
Vector operator-( const Vector & b ) const { return Vector(x-b.x,y-b.y); }
Vector operator*( double b ) const { return Vector(x*b,y*b); }
Vector operator/( double b ) const { return Vector(x/b,y/b); }
double operator^( const Vector & b ) const { return x*b.y-y*b.x; }
double operator&( const Vector & b ) const { return x*b.x+y*b.x; }
bool operator<( const Vector & b ) const {
return x<b.x || (x-b.x<eps && y<b.y);
}
};
typedef Vector Point; bool onleft( Point &A, Point &B, Point &P ) {
return sg((B-A)^(P-A)) > ;
}
int convex( int n, Point *p, Point *c ) {
int m;
sort( p, p+n );
c[m=] = p[];
for( int i=; i<n; i++ ) {
while( m> && !onleft(c[m-],c[m],p[i]) ) m--;
c[++m] = p[i];
}
int k=m;
for( int i=n-; i>=; i-- ) {
while( m>k && !onleft(c[m-],c[m],p[i]) ) m--;
c[++m] = p[i];
}
return m+(n==);
}
double area( Point &A, Point &B, Point &P ) {
return (B-A)^(P-A);
}
double maxarea( int n, Point *p ) {
if( n<= ) return 0.0;
if( n== ) return fabs(area(p[],p[],p[])); static int nxt[N];
nxt[n-]=;
for( int i=; i<n-; i++ ) nxt[i]=i+; double rt = 0.0;
for( int i=; i<n; i++ ) {
for( int j=nxt[nxt[i]],a=nxt[i],b=nxt[j]; nxt[j]!=i; j=nxt[j] ) {
while( area(p[i],p[a],p[j])<area(p[i],p[nxt[a]],p[j]) ) a=nxt[a];
while( area(p[j],p[b],p[i])<area(p[j],p[nxt[b]],p[i]) ) b=nxt[b];
double ra = area(p[i],p[a],p[j]);
double rb = area(p[j],p[b],p[i]);
rt = max( rt, ra+rb );
}
}
return rt/2.0;
} int n, cn;
Point pts[N], cvx[N]; int main() {
scanf( "%d", &n );
for( int i=; i<n; i++ )
scanf( "%lf%lf", &pts[i].x, &pts[i].y );
cn = convex( n, pts, cvx );
printf( "%.3lf\n", maxarea(cn,cvx) );
}
bzoj 1069的更多相关文章
- BZOJ 1069 Luogu P4166 最大土地面积 (凸包)
题目链接: (bzoj)https://www.lydsy.com/JudgeOnline/problem.php?id=1069 (luogu)https://www.luogu.org/probl ...
- 【BZOJ 1069】 凸包+旋转卡壳
1069: [SCOI2007]最大土地面积 Description 在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. Input 第 ...
- bzoj 1069 [SCOI2007]最大土地面积(旋转卡壳)
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2277 Solved: 853[Submit][Stat ...
- BZOJ 1069 最大土地面积
Description 在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. Input 第1行一个正整数N,接下来N行,每行2个数x,y ...
- BZOJ 1069: [SCOI2007]最大土地面积 [旋转卡壳]
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 2978 Solved: 1173[Submit][Sta ...
- ●BZOJ 1069 [SCOI2007]最大土地面积
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1069 题解: 计算几何,凸包,旋转卡壳 其实和这个题差不多,POJ 2079 Triangl ...
- bzoj 1069 [SCOI2007]最大土地面积——旋转卡壳
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1069 发现 n 可以 n^2 .所以枚举对角线,分开的两部分三角形就可以旋转卡壳了. 注意坐 ...
- BZOJ 1069: [SCOI2007]最大土地面积(旋转卡壳)
题目链接~ 1069: [SCOI2007]最大土地面积 思路很简单,极角排序求完凸包后,在凸包上枚举对角线,然后两边分别来两个点旋转卡壳一下,搞定! 不过计算几何的题目就是这样,程序中间的处理还是比 ...
- 【BZOJ 1069】【SCOI 2007】最大土地面积 凸包+旋转卡壳
因为凸壳上对踵点的单调性所以旋转卡壳线性绕一圈就可以啦啦啦--- 先求凸包,然后旋转卡壳记录$sum1$和$sum2$,最后统计答案就可以了 #include<cmath> #includ ...
随机推荐
- bzoj 1014: 洛谷 P4036: [JSOI2008]火星人
题目传送门:洛谷P4036. 题意简述: 有一个字符串,支持插入字符,修改字符. 每次需要查询两个后缀的LCP长度. 最终字符串长度\(\le 100,\!000\),修改和询问的总个数\(\le 1 ...
- MySQL 5.7以后怎么查看索引使用情况?
MySQL 5.7以后怎么查看索引使用情况? 0.在sys库中查看没用的索引 root@localhost [sys]>select * from schema_unused_indexes; ...
- easyui表单提交验证form
方式一,不需要考虑jquery.easyui.min.js版本 <script> $(function () { //针对 设置 novalidate:true $('.validateb ...
- Hash 分布均衡算法
1.移位实现 public static int GetIndex(string str, int count) { , (current, c) => (current << ) ...
- 数据库-mysql触发器
MySQL包含对触发器的支持.触发器是一种与表操作有关的数据库对象,当触发器所在表上出现指定事件时,将调用该对象,即表的操作事件触发表上的触发器的执行. 一:创建触发器 在MySQL中,创建触发器语法 ...
- ubuntu 安装chrome 和chromedriver
1. chromedriver 下载地址: https://npm.taobao.org/mirrors/chromedriver 在这里找到对应的驱动 2. 安装谷歌浏览器 2.1 安装依赖 ap ...
- 洛谷P2300 合并神犇
传送门啦 分析: 刚开始读完题后感觉很懵,怎么算都不是3,结果发现题目理解错了.题目要求的是求一个不降的序列,不是递减的(发现自己好傻) 看明白题就好做了吧.经典的区间dp题,合并果子大家应该都做过, ...
- 浮动元素垂直居中,bootstrap栅格布局垂直居中
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- new[] 到底做了什么?
#include<iostream> #include<cstdlib> using std::cout; using std::endl; using std::hex; c ...
- 使用T-SQL导入多个文件数据到SQL Server中
在我们的工作中,经常需要连续输入多个文件的数据到SQL Server的表中,有时需要从相同或者不同的目录中,同时将文件中的数据倒入.在这篇文章中,我们将讨论如何同时把一个目录中的文件的数据倒入到SQL ...