Why Puang Crossed the Road
InterviewTime limit1sMemory limit512 MB
Given a line Ax+By+C=0 and an axis-aligned rectangle, decide whether the line passes through the rectangle's interior; touching only a corner or edge does not count.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
In Heukseok-dong, a redevelopment project has left a danger zone that must not be crossed. The zone is a rectangle with sides parallel to the X and Y axes.
Puang, the mascot of Chung-Ang University, is passing through Heukseok-dong along a straight-line path. Homin, the ghost of Heukseok-dong, suspects that Puang will cross the danger zone. He plans to determine whether Puang passes through the danger zone and then take action to stop Puang from crossing it.
Write a program for Homin that tells whether Puang passes through the danger zone.
Input
The first line gives the integers A, B, C (-10,000 ≤ A, B ≤ 10,000, -100,000 ≤ C ≤ 100,000). These numbers describe the straight-line path Puang follows, expressed on the coordinate plane in the form Ax+By+C=0. (The case where both A and B are 0 is not given, since it is not the equation of a line.)
The second line gives the integers X1, X2, Y1, Y2 (-100,000 ≤ X1 < X2 ≤ 100,000, -100,000 ≤ Y1 < Y2 ≤ 100,000). The edges of the rectangle are contained in the lines x = X1, x = X2, y = Y1, and y = Y2.
Output
On the first line, print “Poor” if Puang passes through the danger zone, and “Lucky” otherwise. Passing through only a corner of the danger zone, or running only along its edges, counts as not passing through the danger zone.