POJ 2653:http://poj.org/problem?id=2653
The idea is very simple, that is, on the ground in order to sprinkle a pair of sticks, to see how many are finally pressed, the output is not pressed the number of the stick. A bit of a pit is not clear how to calculate the stick, also do not know whether the norms intersect ... And I judged it, including the endpoint overlap and partial intersection.
Train of thought: first I want to traverse from the back, to find each side, to see whether he was pressed to the edge before, if the pressure to the previous change mark, the final statistics are not marked, but tle ... Can only start looking from the front, traversing each edge is the back of the pressure over, the pressure on the direct break, if all did not press, save this edge, the final output.
int n;
struct point {double x, y;}; struct Line {point A, B;}
L[100010];
int ans[100010];
Double Xmult (Point P1, point P2, point P) {return (p1.x-p.x) * (P2.Y-P.Y)-(p2.x-p.x) * (P1.Y-P.Y);}
Three points collinear int dots_inline (point p1,point p2,point p3) {return zero (Xmult (P1,P2,P3));} Two points on the same side of the line, points on the line return 0//More Highlights: Http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/int Same_side (Point
P1,point p2,line L) {return Xmult (l.a,p1,l.b) *xmult (l.a,p2,l.b) >eps;} Whether the sentencing point is on a segment, including the endpoint int dot_online_in (Point p,line L) {return zero (Xmult (p,l.a,l.b)) && (l.a.x-p.x) * (l.b.x-p.x) &L
t;eps&& (L.A.Y-P.Y) * (L.B.Y-P.Y) <eps; ///the intersection of two segments, including endpoints and partially coincident int intersect_in (line U,line v) {if (!dots_inline (U.A,U.B,V.A) | |!
Dots_inline (U.A,U.B,V.B)) return!same_side (u.a,u.b,v) &&!same_side (v.a,v.b,u); Return dot_online_in (u.a,v) | | Dot_online_in (u.b,v) | | Dot_online_in (v.a,u) | |
Dot_online_in (V.b,u);
} void Solve () { while (~SCANF ("%d", &n) && N) {for (int i = 0; i < n; ++i) {scanf ("%lf%lf
%lf%lf ", &l[i].a.x, &l[i].a.y, &l[i].b.x, &L[I].B.Y);
int t = 0;
for (int i = 0; i < n; ++i) {bool flag = true;
for (int j = i+1; j < n; ++j) {if (intersect_in (l[i), L[j]) {
Flag = false;
Break
} if (flag) {ans[t++] = i+1;
} printf ("Top sticks:");
for (int i = 0; i < t-1 ++i) {printf ("%d,", ans[i]);
printf ("%d.\n", N); }
}