eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків

Frames

Vasya and Petya are playing an interesting game. Rules are pretty easy: there are two frames, the players have to make a translation of the second frame in such a way that the area of the intersection of the frames would be as large as possible. Both players think for a minute, and write down the translation vector of the second frame. The player whose vector gives a larger intersection area wins. The game has many subtle cases, so Vasya wants to cheat and write a program that finds the best translation vector. For this game the \textit{frame} is a difference of two rectangles: the inner one and the outer one. The inner rectangle lies strictly inside the outer one. Sides of both rectangles are parallel to the coordinate axes. To make the definition more clear let us consider some examples. The area of the frame is (\textbf{W}·\textbf{H} - \textbf{w}·\textbf{h}), where \textbf{W}, \textbf{H} - dimensions of the outer rectangle and \textbf{w}, \textbf{h} - dimensions of the inner one (\textbf{0} < \textbf{w} < \textbf{W}; \textbf{0} < \textbf{h} < \textbf{H}). Write a program that finds a translation of one frame relative to another that results in maximum frames intersection area. \InputFile Each frame is described by four points - two opposite corners of the outer rectangle, followed by two opposite corners of the inner rectangle. Points are described by their coordinates - pairs of integer numbers \textbf{x} and \textbf{y}. Coordinates do not exceed \textbf{10^8} by absolute value. The first line of the input file contains the description of the first frame. The second line of the input file contains the description of the second frame. \OutputFile The first line of the output file must contain an integer number \textbf{A} - the maximal possible intersection area of the given two frames achievable by a translation. The second line of the output file must contain a pair of integer numbers \textbf{x} and \textbf{y} - coordinates of the translation vector of the second frame that provides the intersection area \textbf{A}. Coordinates must not exceed \textbf{10^18} by the absolute value.
Ліміт часу 3 секунди
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
2 2 5 6 3 3 4 5
0 0 10 10 2 2 3 3
Вихідні дані #1
10
0 -3
Автор Yuriy Petrov, Sergey Kopeliovich