Bzoj 1069 [SCOI2007] maximum land area rotation jam

Source: Internet
Author: User

Test Instructions:Link Method:Rotating Jam parsing:It's like the POJ2079 triangle. So the idea is actually a train of thought. But notice that the subject is to look for the four-sided shape, if you find three moving points, it seems unrealistic. So we enumerate diagonal words, there must be a point diagonally up and down, and found the point below the counter-clockwise rotation, the above point is actually counterclockwise. So according to the idea of rotating jam, we need to enumerate the diagonal, and then find two dynamic point update maximum. This complexity is O (n^2)-enumerated fixed point and its diagonal point, for the subject can be too. Code:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 50010#define EPS 1e-8using namespace STD;intNstructpoint{Doublex, y;friendistream&operator>> (IStream &_,point &a) {scanf("%LF%LF", &AMP;A.X,&AMP;A.Y);return_; } point () {}, point (DoubleADoubleb): X (a), Y (b) {} pointoperator+ (ConstPoint &a) {returnPoint (X+A.X,Y+A.Y);} Pointoperator- (ConstPoint &a) {returnPoint (X-A.X,Y-A.Y);} Pointoperator* (DoubleRate) {returnPoint (X*rate,y*rate);}Double operator* (ConstPoint &a) {returnX*A.X+Y*A.Y;}Double operator^ (ConstPoint &a) {returnx*a.y-y*a.x;}friend BOOL operator< (point A,point b) {if(a.x==b.x)returna.y>b.y;returna.x<b.x; }}pt[n];intSta[n];intStaa[n];intTopintToppDoubleRotating_calipers () {Doubleret=0; for(intI=0; i<topp;i++) {intp=1, q=1; for(intj=i+2; j<topp;j++) { while(((pt[staa[p+1]]-pt[staa[i]] ^ (pt[staa[j]]-pt[staa[i])) > ((pt[staa[p]]-pt[staa[i]) ^ (pt[staa[j]]-pt[staa[i]))) P= (p+1)%topp; while(((pt[staa[j]]-pt[staa[i)] ^ (pt[staa[q+1]]-pt[staa[i]]) > (pt[staa[j]]-pt[staa[i]) ^ (pt[staa[q]]-pt[staa[i])) q= (q+1)%topp; Ret=max (ret, ((Pt[staa[p]]-pt[staa[i]) ^ (Pt[staa[j]]-pt[staa[i])) + ((Pt[staa[j]]-pt[staa[i]) ^ (pt[staa[q]]-pt[s        Taa[i])); }    }returnRET;}intMain () { while(~scanf("%d", &n) &&n!=-1)    { for(intI=1; i<=n;i++)Cin>>pt[i]; Sort (pt+1, pt+n+1); top=0, topp=-1; for(intI=1; i<=n;i++) { while(top>1&& ((Pt[i]-pt[sta[top]) ^ (pt[sta[top]]-pt[sta[top-1]]) >=0) top--;        Sta[++top]=i; } for(intI=1; i<top;i++) {staa[++topp]=sta[i]; } top=0; for(intI=1; i<=n;i++) { while(top>1&& ((Pt[i]-pt[sta[top]) ^ (pt[sta[top]]-pt[sta[top-1]]) <=0) top--;        Sta[++top]=i; } for(inti=top;i>=1; i--) {staa[++topp]=sta[i]; }printf("%.3lf\n", Rotating_calipers ()/2.0); }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Bzoj 1069 [SCOI2007] maximum land area rotation jam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.