Semi-convex package. Not at all. The membrane of the Huang long ... Tall on the Ah ... At the beginning, the const int eps=1e-8 wa ...
#include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include < algorithm>using namespace std; #define REP (i,n) for (int i=1;i<=n;i++) const int Nmax=50005;const double eps=1e-8; struct edge{double a,b;int num;}; Edge Edges[nmax];bool cmp (Edge X,edge y) {if (Fabs (X.A-Y.A) <eps) return X.b<y.b;return x.a<y.a;} Double Crossx (Edge X,edge y) {return (Y.B-X.B)/(X.A-Y.A);} Edge S[nmax];int Ans[nmax];int Main () {int n;scanf ("%d", &n), Rep (i,n) scanf ("%lf%lf", &edges[i].a,&edges[i ].B), Edges[i].num=i;sort (EDGES+1,EDGES+N+1,CMP);//rep (i,n) printf ("%lf", edges[i].a); int Top=0;rep (i,n) {Edge o= Edges[i];while (top) {if (Fabs (S[TOP].A-O.A) <eps) Top--;else if (TOP>1&&CROSSX (O,s[top-1]) <=CROSSX ( S[top],s[top-1]) Top--;else break;} S[++top]=o;} Rep (i,top) ans[s[i].num]=1;rep (i,n) if (Ans[i]) printf ("%d", I); return 0;}
1007: [HNOI2008] Horizontal visible line time limit:1 Sec Memory limit:162 MB
submit:5749 solved:2183
[Submit] [Status] [Discuss] Description
There are n linear l1,l2 on the Xoy Cartesian plane,... Ln, if you look down at the Y value as positive infinity, and you see a sub-segment of Li, it is called Li
Visible, otherwise Li is overwritten.
For example, for a line:
L1:y=x; L2:y=-x; L3:y=0
Then L1 and L2 are visible, and L3 are covered.
gives a line of N, expressed as a form of y=ax+b (| a|,| b|<=500000), and the N line 22 does not coincide. Find all the visible lines.
Input
The first behavior n (0 < n < 50000), the next n-line input Ai,bi
Output
From small to large output visible line number, 22 is separated by a space, the last number must also have a space behind
Sample Input3
-1 0
1 0
0 0Sample Output1 2HINT Source [Submit] [Status] [Discuss]
bzoj1007: [HNOI2008] Horizontal visible line