logo AlgoBeat OnlineJudge
登录 注册

#206185. [NWRRC 2017] Intelligence in Perpendicularia

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 -- the number of vertices of the polygon . Each of the following lines contains two integers and the coordinates of the i-th vertex 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 horizontal 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

数据范围与提示

Time limit: 3 s, Memory limit: 512 MB.