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 ...
随机推荐
- 关于new Handler()与new Handler(Looper.getMainLooper())区别
如果你不带参数的实例化:Handler handler=new Handler();那么这个会默认用当前线程的Looper对象. 一般而言,如果你的Handler是要用来刷新UI的,那么就需要在主线程 ...
- C# WebClient、 jsonp实现跨域
WebClient 无传输数据获取 Uri uri = new Uri(allURL); WebClient wc = new WebClient(); wc.Encoding = System.Te ...
- Windows执行命令与下载文件总结
1.前言 在渗透或是病毒分析总是会遇到很多千奇百怪的下载文件和执行命令的方法. 2.实现方式 2.1.Powershell win2003.winXP不支持 $client = new-object ...
- aarch64_o1
OCE-devel-0.18.1-1.fc26.aarch64.rpm 2017-05-16 03:37 5.4M fedora Mirroring Project OCE-draw-0.18.1-1 ...
- 转载:Github项目解析(七)-->防止按钮重复点击
不错的东西,记录下... http://46aae4d1e2371e4aa769798941cef698.devproxy.yunshipei.com/qq_23547831/article/deta ...
- go语言 documentation
Documentation文档 The Go programming language is an open source project to make programmers more pro ...
- Python访问MySQL(1):初步使用PyMySQL包
Windows 10家庭中文版,MySQL 5.7.20 for Win 64,Python 3.6.4,PyMySQL 0.8.1,2018-05-08 ---- 使用Python访问MySQL数据 ...
- pip3
pip3 install django #安装rabbitmq连接模块 pip3 install pika pip3 install paramiko pip3 install ipython pip ...
- 铁轨(UVa 514)
利用栈实现 C++11 代码如下: #include<iostream> #include<stack> using namespace std; #define maxn 1 ...
- day10--异步IO\数据库\队列\缓存
上节回顾: 线程 vs 进程 https://www.cnblogs.com/alex3714/articles/5230609.html https://www.cnblogs.com/alex ...