Line Segment Intersection 4
Time limit1sMemory limit512 MB
Given N line segments with integer endpoints, determine whether any two segments intersect, counting endpoint touches and overlaps as intersections.
Problem
A set of N line segments is given on the two-dimensional coordinate plane. Determine whether there exist two segments that intersect. If an endpoint of one segment lies on another segment or coincides with another segment's endpoint, the two segments count as intersecting.
Input
The first line contains the number of segments N. Each of the next N lines contains four integers x1, y1, x2, y2, which are the two endpoints (x1, y1) and (x2, y2) of a segment.
Output
If there are two intersecting segments, print 1. Otherwise, print 0.
Constraints
- 1 ≤ N ≤ 200,000
- and are integers.
- Each segment has a length greater than 0.