Semi-planar intersection simplified version.
#include <cstdio> #include <algorithm> #include <cmath> using namespace std;
const int maxn=500010;
const double eps=1e-8;
int cmp (double x) {if (x>=eps) return 1;
if (fabs (x) <=eps) return 0;
return-1;
struct Vector {double x,y;
Vector operator + (const vector &v) const {return (Vector) {x+v.x,y+v.y};
Vector operator-(const vector &v) const {return (Vector) {x-v.x,y-v.y};
Vector operator * (const double &k) const {return (Vector) {x*k,y*k};
}}P[MAXN];
typedef Vector Point; Double dot (vector v,vector u) {return v.x*u.x+v.y*u.y.} Double Cross (vector v,vector u) {return v.x*u.y-v.y*u.x
;
} struct line {point P;
Vector v;
int id;
/*double angle () const {return atan2 (v.y,v.x);
}*/BOOL Operator < (const line &l) Const {return CMP (V.Y-L.V.Y) ==-1;
}}A[MAXN],Q[MAXN];
Point intersection (line l,line m) { Vector U=L.P-M.P;
Double T=cross (m.v,u)/cross (L.V,M.V);
return l.p+l.v*t;
int N,ANS[MAXN];
int main () {//freopen ("e.in", "R", stdin);
Freopen ("E.out", "w", stdout);
Freopen ("Bzoj_1007.in", "R", stdin);
Freopen ("Bzoj_1007.out", "w", stdout);
int hd,tl;
Double x,y;
scanf ("%d", &n);
for (int i=1;i<=n;i++) {scanf ("%lf%lf", &x,&y);
A[i]= (line) {(point) {0,y}, (Vector) {1,x},i};
Sort (a+1,a+n+1);
Q[HD=TL=1]=A[1];
for (int i=2;i<=n;i++) {while (HD<TL&&CMP (Cross (A[I].V,P[TL-1]-A[I].P)) <=0) tl--;
while (HD<TL&&CMP (Cross (A[I].V,P[HD]-A[I].P)) <=0) hd++;
if (Q[tl]<a[i]) q[++tl]=a[i];
else if (CMP (cross (A[I].V,Q[TL].P-A[I].P)) <=0) q[tl]=a[i];
if (HD<TL) p[tl-1]=intersection (Q[tl-1],q[tl]);
}//while (hd<tl-1&&cmp (Cross (Q[1].V,P[TL-1]-Q[1].P)) <=0) tl--;
for (int i=hd;i<=tl;i++) ans[q[i].id]=1; for (int i=1;i<=n;i++) if (Ans[i]) printf ("%d", I);}