Link:
#include <stdio.h>int main(){ puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/46591735");}
Exercises
The convex hull is first asked and then:
Enumeration points i , and then for Point J Get the i And J (ordered) The point in the middle, and J And i (ordered) The point in the middle, is monotonous.
Code:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 2050#define EPS 1e-7using namespace STD;structpoint{Doublex, y;voidRead () {scanf("%LF%LF", &x,&y);} Point (Double_x=0,Double_y=0): X (_x), Y (_y) {}BOOL operator< (ConstPoint &a)Const{returnx==a.x?y<a.y:x<a.x;}Double operator- (ConstPoint &a)Const{return sqrt((x-a.x) * (x-a.x) + (Y-A.Y) * (Y-A.Y));}} P[n],zero;intNDoubleXmul (ConstPoint &a,ConstPoint &b,ConstPoint &c) {return(C.Y-A.Y) * (b.x-a.x)-(B.Y-A.Y) * (c.x-a.x);}structqiu_tu_bao{//The name is so cock, don't you come to beat me intSTK1[N],TOP1,STK2[N],TOP2; Point Tp[n];voidWork () {intI stk1[top1=1]=1; for(i=2; i<=n;i++) { while(top1>1&&xmul (p[stk1[top1-1]],p[stk1[top1]],p[i] >-eps) top1--; Stk1[++top1]=i; } stk2[top2=1]=n; for(i=n-1; i;i--) { while(top2>1&&xmul (p[stk2[top2-1]],p[stk2[top2]],p[i] >-eps) top2--; Stk2[++top2]=i; } n=0; for(i=1; i<top1;i++) Tp[++n]=p[stk1[i]]; for(i=1; i<top2;i++) Tp[++n]=p[stk2[i]];memcpy(P,TP,sizeof(point) * (n+1)); }}QTB;intF[n][n];#define RIG (x, y) ((x+y-1)%n+1)#define LEF (x, y) ((x-y+n-1)%n+1)inline DoubleArea (intLintRintx) {DoubleRet=xmul (Zero,p[l],p[r]); Ret+=xmul (Zero,p[r],p[x]); Ret+=xmul (Zero,p[x],p[l]);returnRET;}inline BOOLCheckintLintRintAintb) {returnArea (l,r,a) <area (l,r,b);}intMain () {intI,j,k;intA,b,c; Zero=point (0,0);scanf("%d", &n); for(i=1; i<=n;i++) P[i].read (); Sort (p+1, p+n+1); Qtb.work (); for(i=1; i<=n;i++) {F[i][rig (I,2)]=rig (I,1); for(J=rig (I,3); Rig (J,1)!=i;j=rig (J,1) {F[i][j]=f[i][lef (J,1)]; while(Rig (F[I][J),1)!=j&& Check (i,j,f[i][j],f[i][j]+1)) f[i][j]++; } }Doublecn1=0.0; for(i=1; i<=n;i++) for(J=rig (I,2); Rig (J,1)!=i;j=rig (J,1)) Ans=max (Ans,area (i,j,f[i][j)) +area (i,f[j][i],j));printf("%.3lf\n", ans/2.0);return 0;}
"BZOJ1069" "SCOI2007" convex hull monotonicity of maximum land area