eolymp
bolt
Try our new interface for solving problems
Problems

Segment and a rectangle

Segment and a rectangle

Пересекаются ли отрезок \textbf{(X_1}, \textbf{Y_1)}, \textbf{(X_2}, \textbf{Y_2)} и прямоугольник с концами диагонали \textbf{(X_3}, \textbf{Y_3)}, \textbf{(X_4}, \textbf{Y_4)} и сторонами параллельными координатным осям? Прямоугольник и отрезок перескаются, если они имеют хотя бы одну общую точку. \InputFile The first line contains four integers \textbf{X_1}, \textbf{Y_1}, \textbf{X_2}, \textbf{Y_2} - the coordinates of the endpoints recorded by a space. The second line contains four integers \textbf{X_3}, \textbf{Y_3},\textbf{ X_4}, \textbf{Y_4} - coordinates of the ends of one diagonal recorded by a space. All coordinates are integers and do not exceed in modulus \textbf{50}. \OutputFile Bring out one number \textbf{1}, if a rectangle and cut intersect or \textbf{0} if not.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1 3 4 -1
-1 4 3 -2
Output example #1
1