Link:
#include <stdio.h>int main(){ puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/46608743");}
Exercises
For a point pair, if it's connected to the equation of the x is a vertical line, then I can put all the points x Is the first key value, y Sort the second key value, and then the first point at each end of the line is a triangle with the segment, and the area of the bar may update the answer.
Then we can order all the lines according to the slope first, and then we find that each time we modify the Y axis sequentially, we can O(1) Gets the sequence of points after the rotated coordinate system.
You can observe this figure (this is a small exception benefit):
Uh. That is, each time you rotate to a slope, it is oblique before the rotation. a ? > Span class= "Mi" id= "mathjax-span-22" style= "font-family:mathjax_math-italic; Padding-left:0.274em; " >b ) , and turn it into a vertical b ? > Span class= "Mi" id= "mathjax-span-30" style= "font-family:mathjax_math-italic; Padding-left:0.274em; " >a ) , just a simple exchange A,B The position in the sequence is good ~ For example:
Code:
(I'm not going to tell you though AC, but it looks like where it hangs when it's measured) qwq
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 1010#define INF 1e60#define AREA (A,B,C) ABS (Xmul (A, B) +xmul (b,c) +xmul (c,a))using namespace STD;structpoint{Doublex, y;voidRead () {scanf("%LF%LF", &x,&y);}BOOL operator< (ConstPoint &a)Const{returnx<a.x;}} P[n],zero;intId[n],cr[n];structline{intU,v;//DOT marking ... DoubleKvoidKeepint_u,int_V) {u=_u,v=_v,k= (P[U].Y-P[V].Y)/(p[u].x-p[v].x);}BOOL operator< (ConstLine &a)Const{returnK<A.K;}} L[n*n];inline DoubleXmul (Point b,point c,point A=zero) {return(C.Y-A.Y) * (b.x-a.x)-(B.Y-A.Y) * (c.x-a.x);}intN,m;DoubleAns=inf;voidWorkintUintV) {if(Id[u]>id[v]) swap (U,V);if(id[u]>1) Ans=min (Ans,area (p[u],p[v],p[cr[id[u]-1]]));if(id[v]<n) Ans=min (Ans,area (p[u],p[v],p[cr[id[v]+1]])); Swap (Id[u],id[v]), cr[id[u]]=u,cr[id[v]]=v;}intMain () {//Freopen ("Test.in", "R", stdin); intI,j;scanf("%d", &n); for(i=1; i<=n;i++) {p[i].read (); Id[i]=cr[i]=i; } sort (p+1, p+n+1); for(i=1; i<=n;i++) for(j=i+1; j<=n;j++) L[++m].keep (I,J); Sort (L +1, l+m+1); for(i=1; i<=m;i++) work (L[I].U,L[I].V);printf("%.2lf\n", ans/2.0);return 0;}
"BZOJ3707" enclosure calculates the geometric rotation coordinate system