Line Segment Intersection 2
InterviewTime limit0.25sMemory limit512 MB
Given two line segments by their integer endpoints, decide whether they intersect, counting endpoint touching as an intersection.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Given two line segments and in the two-dimensional coordinate plane, determine whether the two segments intersect. A case where an endpoint of one segment lies on the other segment or on its endpoint also counts as an intersection.
The endpoints of are and , and the endpoints of are and .
Input
The first line gives the endpoints of , and the second line gives the endpoints of .
Output
Print 1 if and intersect, and 0 otherwise.
Constraints
- are integers.
- Each segment has length greater than 0.