Logo
(追記) (追記ここまで)

3365번 - Building a Fence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB73350.000%

문제

Leopold is indeed a lucky fellow. He just won a huge estate in the lottery. The estate contains several grand buildings in addition to the main mansion, in which he intends to live from now on. However, the estate lacks a fence protecting the premises from trespassers, which concerns Leopold to a great extent. He wants to build a fence and, in order to save money, he decides it is sufficient to have a fence that encloses the main mansion, except for one important restriction: the fence must not lie too close to any of the buildings. To be precise, seen from above, each building is enclosed in a surrounding forbidden rectangle within which no part of the fence may lie. The rectangles’ sides are parallel to the x- and y-axis. Each part of the fence must also be parallel either to the x-axis or the y-axis.

Help Leopold to compute the minimum length of any allowed fence enclosing the main mansion.

Figure 1: The main mansion (black) and three other buildings with surrounding forbidden rectangles. The thick black line shows a shortest allowed fence enclosing the main mansion.

입력

The first line of the input file contains a positive integer m (1 ≤ m ≤ 100), the number of buildings of the estate. Then follow m lines each describing a forbidden rectangle enclosing a building. Each row contains four space-separated integers tx, ty, bx, and by, where (tx, ty) are the coordinates of the upper left corner and (bx, by) the coordinates of the bottom right corner of the rectangle. All coordinates obey 0 ≤ tx < bx ≤ 10,000 and 0 ≤ ty < by ≤ 10,000. The first rectangle is the forbidden rectangle enclosing the main mansion.

출력

It contains one line with a single positive integer equal to the minimum length of any allowed fence enclosing the main mansion.

제한

예제 입력 1

4
8 4 13 8
2 1 6 7
4 7 9 11
14 7 19 11

예제 출력 1

32

힌트

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2007 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /