Uyuw ' s Concert
Time Limit: 6000MS |
|
Memory Limit: 65536K |
Total Submissions: 8580 |
|
Accepted: 3227 |
Description
Prince remmarguts solved the CHESS puzzle successfully. As an award, Uyuw planned-to-hold a concert in a huge piazza named after its great designer Ihsnayish.
The piazza in udf-united Delta of Freedom ' s downtown is a square of [0, 10000] * [0, 10000]. Some Basket chairs had been standing there for years, but in a terrible mess. Look at the following graph.
In this case we had three chairs, and the audiences face the direction as what Arrows had pointed out. The chairs were old-aged and too heavy to be moved. Princess Remmarguts told the Piazza's current owner, Mr. UW, to build a large stage inside it. The stage must is as large as possible, but he should also make sure the audience in every position of every chair would b e able to see the stage without turning aside (that means the stage was in the forward direction of their own).
To make it simple, the stage could is set highly enough to make sure even thousands of chairs were in front of you, as Lon G As you are were facing the stage, you would is able to see the SINGER/PIANIST–UYUW.
Being a mad Idolater, can you tell them the maximal size of the stage?
Input
In the first line, there's a single non-negative integer n (n <= 20000), denoting the number of basket chairs. Each of the following lines contains-floating numbers x1, y1, x2, y2, which means there ' s a basket chair on the line Segment of (x1, y1) – (x2, y2), and facing to it left (which a point (x, y) are at the left side of this segment means (x–x1) * (Y–y2) – (x–x2) * (y–y1) >= 0).
Output
Output a single floating number, rounded to 1 digit after the decimal point. The maximal area of the stage.
Sample Input
310000 10000 0 500010000 5000 5000 100000 5000 5000 0
Sample Output
54166666.7
Hint
Sample input is the same as the graph above and while the correct solution for it is as below:
I suggest that you the use of Extended in Pascal and a long double in C + + to avoid precision error. But the standard program is only uses double.
Source
POJ Monthly,zeyuan Zhu
Ideas
Half-plane intersection.
Note Set the bounds, input vector direction and EPS selection, 1e-10 enough.
Code
1#include <cmath>2#include <cstdio>3#include <vector>4#include <cstring>5#include <algorithm>6 #definefor (A,B,C) for (int a= (b); a<= (c); a++)7 using namespacestd;8 9 Const intEPS = 1e-Ten;Ten One structPt { A Doublex, y; -Pt (Doublex=0,Doubley=0): X (x), Y (y) {} - }; the typedef Pt VEC; - -Vecoperator-(Pt a,pt b) {returnVEC (a.x-b.x,a.y-b.y); } -Vecoperator+ (VEC A,vec b) {returnVEC (a.x+b.x,a.y+b.y); } +Vecoperator* (Vec A,Doublex) {returnVEC (a.x*x,a.y*x); } - + DoubleCross (Pt a,pt b) {returna.x*b.y-a.y*b.x;} A at structLine { -Pt p; VEC v;Doubleang; - Line () {} -Line (Pt P,vec v):p (P), V (v) {ang=atan2 (v.y,v.x);} - BOOL operator< (Constline& RHS)Const { - returnAng <Rhs.ang; in } - }; to //p on the left of L + BOOLOnleft (line l,pt p) {returnCross (L.V,P-L.P) >0; } - Pt Getlineinter (line A,line b) { theVEC u=a.p-B.P; * DoubleT=cross (b.v,u)/Cross (A.V,B.V); $ returna.p+a.v*T;Panax Notoginseng } - theVector<pt> HPI (vector<line>L) { + intn=l.size (); A sort (L.begin (), L.end ()); the intF,r; +Vector<pt>p (n), ans; -Vector<line>q (n); $Q[f=r=0]=l[0]; $ for(intI=1; i<n;i++) { - while(F<r &&!onleft (l[i],p[r-1])) r--; - while(F<r &&!onleft (l[i],p[f)) f++; theq[++r]=L[i]; - if(Fabs (Cross (q[r].v,q[r-1].V)) <EPS) {Wuyir--; the if(Onleft (Q[R],L[I].P)) q[r]=L[i]; - } Wu if(F<r) p[r-1]=getlineinter (q[r-1],q[r]); - } About while(F<r &&!onleft (q[f],p[r-1])) r--; $ if(r-f<=1)returnans; -p[r]=Getlineinter (q[r],q[f]); - for(inti=f;i<=r;i++) Ans.push_back (P[i]); - returnans; A } +Vector<line>L; theVector<pt>p; - intN; $ the intMain () { the //freopen ("in.in", "R", stdin); the //freopen ("Out.out", "w", stdout); thescanf"%d",&n); - DoubleX1,y1,x2,y2; in for(intI=0; i<n;i++) { thescanf"%LF%LF%LF%LF",&x1,&y1,&x2,&y2); the Pt A (x1,y1), B (x2,y2); AboutL.push_back (Line (a,b-a)); the } thePt A (0,0), B (10000,0), C (10000,10000), D (0,10000); theL.push_back (Line (a,b-a)); +L.push_back (Line (b,c-b)); -L.push_back (Line (c,d-c)); theL.push_back (Line (d,a-d));Bayip =HPI (L); the Doubleans=0;intm=p.size (); the for(intI=1; i<m-1; i++) -Ans + = Cross (p[i]-p[0],p[i+1]-p[0]); -printf"%.1LF", ans/2); the return 0; the}
POJ 2451 Uyuw ' s Concert (semi-flat cross)