Cow Optics
Time limit1sMemory limit128 MB
Count empty integer points where one added 45-degree mirror steers the northbound laser from the origin to the barn through the existing mirrors.
- Level
Medium6 of 10
- Topics
- Simulation, Sorting, Geometry
- Solved
- No attempts yet
Problem
A laser at points north toward a barn at . cows already hold 45-degree mirrors ( or ) at distinct integer points. Bessie may place one more mirror at an empty integer point (not and not an existing cow) so the laser reaches the barn. Count valid locations. Mirrors reflect axis-aligned beams: maps north to west, west to north, south to east, east to south; maps north to east, east to south, south to west, west to north.
Input
Line 1: , , . Next lines: mirror , , orientation ( or ). Coordinates are integers in .
Output
One integer: the number of valid placement locations.