#Lutece0122. Visible Segments

Visible Segments

Migrated from Lutece 122 Visible Segments

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

The central problem to computer graphics is rendering, where we only display visible objects for a given viewpoint. The problem in general, in three dimension world with arbitrary shape, is very difficult. As a student in college, you are encouraged to study some simpler cases at first.

Here we describe a special case of visibility problem. The scenario is restricted to a plane, and the object is only segment. Initially, lots of disjoint segments are placed in the plane arbitrarily. The viewpoint pp is fixed at the origin (i.e. (0,0)(0, 0)), and doesn’t lie on any of the segments. Our task is to determine all the segments we can see from PP. More precisely, a segment SS can be seen from PP if and only if there exists a point qq on SS, the segment pq\overline{pq} doesn’t intersect any segment SS’ other than SS. For example, the following figure has three non-visible segments from pp, they are L1L_1, L3L_3 and L0L_0.

.

Input

The first line contains one integer nn (0<n100,0000 < n \leq 100,000), which is the number of segments. Followed are nn lines, where each line contains four integers x1x_1, y1y_1, x2x_2, y2y_2 (10,000x1,y1,x2,y210,000-10,000 \leq x_1, y_1, x_2, y_2 \leq 10,000) to represent two end points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) of a segment.

Output

List all visible segments in ascending order (each one in a line, index starts from 00).

Samples

4
1 1 2 2
-2 -4 1 -4
-1 -2 2 -2
-3 0 0 3
2
3

Note

  1. Given any segment SS, whose two ends are v1v_1 and v2v_2. SS is invisible to pp if pp, v1v_1 and v2v_2 are collinear;
  2. Given any two segments S1S_1 and S2S_2, v1v_1 is one of S1S_1’s end points, and v2v_2 is one of S2S_2’s. If v2v_2 is on the line of pv1\overline{pv_1}, we say v2v_2 is not visible to pp.

You can notice these two cases in the figure; they are L1L_1 and L3L_3 respectively.

Resources

The 8th UESTC Programming Contest Final