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

15139번 - Intelligence in Perpendicularia 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB55474586.538%

문제

There are only two directions in Perpendicularia: vertical and horizontal. Perpendicularia government are going to build a new secret service facility. They have some proposed facility plans and want to calculate total secured perimeter for each of them.

The total secured perimeter is calculated as the total length of the facility walls invisible for the perpendicularly-looking outside observer. The figure below shows one of the proposed plans and corresponding secured perimeter.

Write a program that calculates the total secured perimeter for the given plan of the secret service facility.

입력

The plan of the secret service facility is specified as a polygon.

The first line of the input contains one integer n — the number of vertices of the polygon (4 ≤ n ≤ 1000). Each of the following n lines contains two integers xi and yi – the coordinates of the i-th vertex (−106 ≤ xi, yi ≤ 106). Vertices are listed in the consecutive order.

All polygon vertices are distinct and none of them lie at the polygon’s edge. All polygon edges are either vertical (xi = xi+1 or horizontal (yi = yi+1) and none of them intersect each other.

출력

Output a single integer — the total secured perimeter of the secret service facility.

제한

예제 입력 1

10
1 1
6 1
6 4
3 4
3 3
5 3
5 2
2 2
2 3
1 3

예제 출력 1

6

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2017 I번

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

출처

대학교 대회

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

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