Intersection Points
InterviewTime limit1sMemory limit256 MB
Given an axis-aligned rectangle and a segment per test case, count their shared boundary points, printing 4 for infinite overlap.
- Level
Medium4 of 10
- Topics
- Geometry, Implementation
- Solved
- No attempts yet
Problem
For an axis-aligned rectangle and a line segment, count how many points lie on both the rectangle boundary and the segment. Print 4 when the segment overlaps the boundary and there are infinitely many intersection points.
Input
The first line contains . Each test case gives a rectangle by and , then a segment from to .
Output
For each test case, print the finite intersection count, or 4 when the intersections are infinite.