Find the Intersections

5

1 votes
Geometry, Mathematics, Line Sweep Technique, Easy-Medium, Line segment, Mathematics
Problem

Given a set of N line segments, you need to find all the intersection points of all the horizontal line segments with all the vertical line segments.Don't consider the coincident endpoints as intersections.

Input:
First line consists of N denoting the number of line segments.
Following N lines consist of ,,, each where represents the starting point of line segment and represents the ending point of line segment.
The line segments would either be horizontal or vertical.

Output:
Print all the intersection points as asked in the question in a separate line in sorted order.The intersection point is represented as (x,y) with space between them.See the sample output for clarity.

Constraints:

For horizontal line:
<
=
For vertical line:
=
<

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The intersections are (2,2) and (3,2)

Editor Image

?