#P10742. [SEERC 2020] Simple Hull

[SEERC 2020] Simple Hull

Problem Description

Gary created a polygon with nn points, where each point has coordinates of the form (x,y)(x,y).

You need to add some edges so that all points are included, and the resulting graph is a "polygonal chain" (that is, each point can be connected to or be connected from at most 22 points, and the drawn edges are allowed to intersect other edges in the graph).

You also need to ensure that for every two points ii and jj that are connected by an edge, the edge formed by these two points is vertical or horizontal in the graph.

Output the minimum possible area of the resulting graph.

Input Format

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

Then follow nn lines, each containing two integers xi,yi (1xi,yi106)x_i,y_i\ (1 \leq x_i,y_i \leq 10^6).

Output Format

Output the area of the resulting nn-gon.

6
1 1
6 1
6 11
11 11
11 6
1 6
50
8
2 4
2 1
4 1
4 3
1 3
1 2
3 2
3 4
6
10
1 1
1 5
4 5
4 3
2 3
2 4
1 4
1 2
4 2
4 1
8

Hint

The graphs drawn for the three samples are, in order:

(The above figures are not drawn to scale.)

Translated by ChatGPT 5