P27731 [洛谷] [SEERC2020] Simple Hull
提高+
题目描述

Problem Description

Gary has created a polygon with \( n \) points, each with coordinates \((x, y)\).

You need to connect some edges to ensure that all points are included, and the resulting graph is a "polygon chain" (i.e., each point can be connected to or from exactly 2 other points, and the edges can intersect with each other in the graph).

You must also ensure that for every pair of points \( i \) and \( j \) that are connected, the edge formed by these two points is either vertical or horizontal.

Output the minimum area of the resulting graph.

Input Format

The first line contains an integer \( n \) \((1 \leq n \leq 10^5)\), representing the number of points.

The next \( n \) lines each contain two integers \( x_i, y_i \) \((1 \leq x_i, y_i \leq 10^6)\).

Output Format

Output the area of the \( n \)-sided polygon formed.

Sample Input and Output

Sample Input #1

6
1 1
6 1
6 11
11 11
11 6
1 6

Sample Output #1

50

Sample Input #2

8
2 4
2 1
4 1
4 3
1 3
1 2
3 2
3 4

Sample Output #2

6

Sample Input #3

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

Sample Output #3

8

Notes

The diagrams for the three samples are as follows:

(The above diagrams are not drawn to scale)

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 1 1 6 1 6 11 11 11 11 6 1 6
样例输出
50