Wire Crossing
Time limit2sMemory limit128 MB
Find the smallest number of wire segments a path between the two given points must cross without passing through a point where wires meet.
- Level
Medium7 of 10
- Topics
- Shortest path, Graph, Geometry
- Solved
- No attempts yet
Problem
In a two-dimensional hardware layout, crossing wires need expensive gadgets. You are given existing straight wires and a new connection from to . The new connection need not be straight, but it may not pass through a point where two or more existing wires already meet.
The start and end points do not lie on an existing wire. Each pair of wires meets in at most one point, and wires do not overlap. Find the minimum number of existing wires that must be crossed, and print that number.
Input
A single test case is given.
- Line 1: , , , , ()
- Next lines: one existing wire from to
Every coordinate has absolute value less than .
Output
Print the minimum number of existing wires that must be crossed to connect the start and end points.