#include #include #include #define eps 1e-9 using namespace std; double f_abs(double x){ return x<0?-x:x; } struct Point{ double x,y; bool up,dn; void disp(){ printf("%lf %lf\n",x,y); } void get(){ scanf("%lf%lf",&x,&y); } bool friend operator<(Point a,Point b){ if(f_abs(a.x-b.x)(Point a,Point b){ return be){ t=s;s=e;e=t; } } void get(){ s.get();e.get(); st(); } }; Line line[200000],myl[2]; Point ep[200000]; int en; double get_cross(Point a,Line b){ double ax,ay,bx,by; ax=b.s.x-a.x; ay=b.s.y-a.y; bx=b.e.x-a.x; by=b.e.y-a.y; return ax*by-ay*bx; } int inter(Line a,Line b,Point &rp=Point()){ double cj[2]; cj[0]=get_cross(b.s,a);cj[1]=get_cross(b.e,a); if(cj[0]*cj[1]>eps)return 0; cj[0]=get_cross(a.s,b);cj[1]=get_cross(a.e,b); if(cj[0]*cj[1]>eps)return 0; if(f_abs(cj[0])eps)return 2; else return 3; }else if(f_abs(cj[1])eps)return 2; else return 3; }else{ double key1=(a.e.x-a.s.x)*(b.e.y-b.s.y); double key2=(b.e.x-b.s.x)*(a.e.y-a.s.y); double key=key1-key2; rp.x=(a.s.y-b.s.y)*(a.e.x-a.s.x)*(b.e.x-b.s.x); rp.x-=key2*a.s.x-key1*b.s.x; rp.x/=key; if(f_abs(b.e.x-b.s.x)