Frames | 프로그래밍의 벗 PivotOJ
PivotOJ

Frames

시간 제한: 3000ms메모리 제한: 256MB출처: NEERC Northern Subregional 2010BOJ 3534
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

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 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.

[이미지 1]   [이미지 2]   [이미지 3]  
Incorrect frames Correct Frames Frames intersection

The area of the frame is (W · H − w · h), where W, H — dimensions of the outer rectangle and w, h — dimensions of the inner one (0 < w < W; 0 < h < H).

Write a program that finds a translation of one frame relative to another that results in maximum frames intersection area.

입력

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 x and y. Coordinates do not exceed 108 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.

출력

The first line of the output file must contain an integer number 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 x and y — coordinates of

the translation vector of the second frame that provides the intersection area A. Coordinates must not exceed 1018 by the absolute value.

예제

예제 1

입력
2 2 5 6 3 3 4 5
0 0 10 10 2 2 3 3
출력
10
1 1
코드를 제출하려면 로그인하세요.