Main topic
Give some points on the plane to find the largest area triangles that can be composed of these points.
Ideas
Although the data range is 50W, but the data on the POJ is always very weak, in the discuss actually someone said:
Manual Two-point discovery of the limit data convex hull with 2,596 points
Rt
Data on Good water
All right, that's all we got left. o ( < Span style= "Position:absolute; Clip:rect (1.976em 1000.003em 2.723em-0.477em); Top: -2.557em; Left:0.003em; " >n 2 ) Solved the problem in a time.
You first find the convex hull, and then you can enumerate one side of the large triangle and then enumerate the other vertex. It's obvious that this process is o ( < Span style= "Position:absolute; Clip:rect (1.976em 1000.003em 2.723em-0.477em); Top: -2.557em; Left:0.003em; " >n 3 ) Of It's obvious that you can use rotational jam to optimize o ( < Span style= "Position:absolute; Clip:rect (1.976em 1000.003em 2.723em-0.477em); Top: -2.557em; Left:0.003em; " >n 2 ) The
CODE
#define _crt_secure_no_warnings#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAX 50010using namespace STD;structpoint{Doublex, y; Point (Double_,Double__): X (_), Y (__) {} point () {}BOOL operator< (ConstPoint &a)Const{if(x = = a.x)returny > a.y;returnx < a.x; } pointoperator+(ConstPoint &a)Const{returnPoint (x + a.x,y + a.y); } pointoperator-(ConstPoint &a)Const{returnPoint (X-A.X,Y-A.Y); } pointoperator*(DoubleAConst{returnPoint (x * a,y * a); }voidRead () {scanf("%LF%LF", &x, &y); }}point[max],Stack[MAX];intTopinline DoubleCross (ConstPoint &p1,ConstPoint &p2) {returnp1.x * p2.y-p1.y * p2.x;}inline voidADD (ConstPoint &p,intBottom) { while(Top > Bottom && Cross (P-Stack[Top-1],Stack[Top]-Stack[Top-1]) >=0)--top;Stack[++top] = p;}intPointsinline DoubleRotatingcaliper () {DoubleRe =. 0; for(inti =1; i < top; ++i) {intp = i +1; for(intj = i +1; J <= Top; ++J) { while(fabs(Cross (Stack[J]-Stack[I],Stack[(P +1)% top]-Stack[j])) >fabs(Cross (Stack[J]-Stack[I],Stack[P]-Stack[j]))) p = (p +1)% Top; RE = max (Re,fabs(Cross (Stack[J]-Stack[I],Stack[P]-Stack(j]))); } }returnRe/2;}intMain () { while(scanf("%d", &points), points +1) { for(inti =1; I <= points; ++i) Point[i]. Read (); Sort (Point +1, point + points +1); top =0;Stack[++top] = point[1]; for(inti =2; I <= points; ++i) Add (Point[i],1);inttemp = top; for(inti = Points-1; I -i) Add (point[i], temp); --top;Stack[0] =Stack[Top];printf("%.2lf\n", Rotatingcaliper ()); }return 0;}
POJ 2079 Triangle Rotating Jam