#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 is fixed at the origin (i.e. ), and doesn’t lie on any of the segments. Our task is to determine all the segments we can see from . More precisely, a segment can be seen from if and only if there exists a point on , the segment doesn’t intersect any segment other than . For example, the following figure has three non-visible segments from , they are , and .
Input
The first line contains one integer (), which is the number of segments. Followed are lines, where each line contains four integers , , , () to represent two end points and of a segment.
Output
List all visible segments in ascending order (each one in a line, index starts from ).
Samples
4
1 1 2 2
-2 -4 1 -4
-1 -2 2 -2
-3 0 0 3
2
3
Note
- Given any segment , whose two ends are and . is invisible to if , and are collinear;
- Given any two segments and , is one of ’s end points, and is one of ’s. If is on the line of , we say is not visible to .
You can notice these two cases in the figure; they are and respectively.
Resources
The 8th UESTC Programming Contest Final