Under construction

Still being built. Things may change

Voronoi Diagram Again

Time limit5sMemory limit1024 MB

Summary
Given N distinct integer points, count the Voronoi regions under Manhattan distance that are unbounded, where ties belong to every nearest point.
Level

Medium6 of 10

Topics
Geometry, Sorting
Solved
No attempts yet

Problem

A Voronoi diagram of a non-empty point set SS divides the plane by the question of which point in SS is closest to a given location. More precisely, for a point set {P1,P2,⋯ ,Pn}\{P_1, P_2, \cdots, P_n\}, a point KK belongs to region ii if and only if d(Pi,K)≤d(Pj,K)d(P_i, K) \le d(P_j, K) holds for all 1≤j≤n1 \le j \le n. The usual Voronoi diagram uses Euclidean distance, but this problem uses Manhattan distance. d(X,Y)d(X, Y) is the Manhattan distance between XX and YY, which is the sum of the absolute differences of their xx and yy coordinates. So the Manhattan distance between (X1,Y1)(X_1, Y_1) and (X2,Y2)(X_2, Y_2) is ∣X2−X1∣+∣Y2−Y1∣|X_2 - X_1| + |Y_2 - Y_1|.

In the figure above, every location on the plane is colored by its closest point. Locations that belong to a single region have a light color, and locations that belong to more than one region form black lines and points.

A region is unbounded if, for any real number RR, there is a point PP in the region with d(O,P)>Rd(O, P) > R, where OO is the origin. Find the number of unbounded regions in the Voronoi diagram.

Input

The first line contains NN, the number of points in the Voronoi diagram. Each of the next NN lines contains two integers xix_i and yiy_i, the coordinates of point PiP_i.

Output

Print a single integer, the number of unbounded regions in the Voronoi diagram.

Constraints

  • 1≤N≤250 0001 \le N \le 250\,000
  • −109≤xi, yi≤109-10^9 \le x_i,\ y_i \le 10^9 (1≤i≤N1 \le i \le N)
  • All NN points are distinct.

Hint

In example 2, the overlapping area is shown as a subtractive mix of two or more colors. Every point with (x≥5∧y≤1)∨(x≤1∧y≥5)(x \ge 5 \wedge y \le 1) \vee (x \le 1 \wedge y \ge 5) belongs to all five regions, so it is colored darkest.

Examples3

  1. Example 1

    Input
    4
    0 0
    -4 0
    3 4
    4 -2
    Expected output
    4
  2. Example 2

    Input
    5
    1 1
    2 2
    3 3
    4 4
    5 5
    Expected output
    5
  3. Example 3

    Input
    9
    -4 -4
    -4 0
    -4 4
    0 -4
    0 0
    0 4
    4 -4
    4 0
    4 4
    Expected output
    8