Time

12:43:59
23 May 2012
Version for print

The Red and Blue Squares

prb48   Petrik and Vasil'ko prepared to the coming test ”perimeter and area of figures”. Petrik drew some geometrical figure. And painted some cells with blue color. Vasil'ko calculated the perimeter of the figure and drew the maximal number of red squares so that the perimeter of new figure remained the same. Write the program, that for the given coordinates of the painted blue squares finds the most amount of red squares that you can draw in such way, that the perimeter of new figure does not change after the set co-ordinates of the painted out dark blue squares.


Specifications

   Input

   The first line contains one number n (0 < n < 40404) - the quantity of blue squares. Each of the next n lines has two numbers x, y (-101 ≤ x, y 101) that contain the coordinates of left lower corners of blue squares. 

   Every blue square has one common point with one of the other blue square. The figure, formed with blue squares, is connected.

   Output

   The number of red squares.


Problem information

Time Limit: 0.1 seconds
Memory Limit: 64 MB
Balls for the passed test: 8.33333
Complexity: 37% 142/225

Example

Example input

3
1 1
2 1
2 2

Example output

1


← The Parquet of the Triangles Problems The Smart Cat →