QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 512 MB 總分: 100

#12720. 垂直线之国的智慧

统计

在 Perpendicularia,只有两个方向:垂直和水平。Perpendicularia 政府计划建造一个新的特勤设施。他们有一些拟定的设施规划,并希望计算其中每一个的总安全周长。

总安全周长计算为垂直于外部观察者视线不可见的设施墙壁的总长度。下图展示了其中一个拟定规划及其对应的安全周长。

编写一个程序,计算给定特勤设施规划的总安全周长。

输入格式

特勤设施的规划由一个多边形指定。

输入的第一行包含一个整数 $n$ —— 多边形的顶点数 ($4 \le n \le 1000$)。 接下来的 $n$ 行,每行包含两个整数 $x_i$ 和 $y_i$ —— 第 $i$ 个顶点的坐标 ($-10^6 \le x_i, y_i \le 10^6$)。顶点按连续顺序给出。

所有多边形顶点各不相同,且没有顶点位于多边形的边上。所有多边形的边要么是垂直的 ($x_i = x_{i+1}$) 要么是水平的 ($y_i = y_{i+1}$),且它们互不相交。

输出格式

输出一个整数 —— 特勤设施的总安全周长。

样例

输入 1

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

输出 1

6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.