Voronoi Diagram Again

시간 제한5초메모리 제한1024 MB

요약
N개의 점이 주어질 때 맨해튼 거리 기준 보로노이 다이어그램에서 무한 영역의 개수를 구한다. 좌표를 변환한 뒤 볼록 껍질 위에 놓인 점의 수를 세면 된다.
난이도

보통10점 중 7점

유형
기하, 정렬, 수학, 구현
정답자
아직 제출이 없습니다

문제


 

In the 2-dimensional Cartesian coordinate system, we define the Voronoi Diagram of a non-empty set of points SS, as a diagram that divides the plane by the criteria ``which point in the set SS is closest in this location?". More precisely, the Voronoi diagram of a given non-empty point set P_1,P_2,⋯ ,P_n\\{P\_1, P\_2, \cdots, P\_n\\} is a collection of \textbf{regions}: A point KK is included in region ii if and only if d(P_i,K)≤d(P_j,K)d(P\_i, K) \le d(P\_j, K) holds for all 1≤j≤n1 \le j \le n. 

While the usual Voronoi Diagram uses Euclidean distance, we use Manhattan distance in this problem. d(X,Y)d(X, Y) denotes the \textbf{Manhattan} distance between point XX and YY. Manhattan distance between two points is the sum of the absolute differences of their XX, YY coordinates. Thus, the Manhattan distance between two points (X_1,Y_1)(X\_1, Y\_1), (X_2,Y_2)(X\_2, Y\_2) can be written as ∣X_2−X_1∣+∣Y_2−Y_1∣|X\_2 - X\_1| + |Y\_2 - Y\_1|.

For example, in the picture above, every location over the plane is colored by the closest point with such location. The points which belongs to a single region is colored by a light color indicating a region, and the points which belongs to more than one region forms lines and points colored black.

The region is unbounded if for any real number RR, there exists point PP in the region such that d(O,P)>Rd(O, P) > R where OO is the origin. You have to find the number of unbounded regions in the Voronoi Diagram.

입력

In the first line, the number of points consisting Voronoi diagram NN is given.

In the ii-th line of next NN lines, two integers x_i, y_ix\_i,\ y\_i indicating xx and yy coordinate of P_iP\_i are given. These are the points in the Voronoi diagram.

출력

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

제한

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

힌트

In example 2, overlapping region is indicated as subtractive mixing of two or more colors. All points with (x≥5∧ y≤1)∨(x≤1∧y≥5)(x \ge 5 \wedge  y \le 1) \vee (x \le 1 \wedge y \ge 5) is included in all five region, and colored as darkest.

예제3

  1. 예제 1

    입력
    4
    0 0
    -4 0
    3 4
    4 -2
    예상 출력
    4
  2. 예제 2

    입력
    5
    1 1
    2 2
    3 3
    4 4
    5 5
    예상 출력
    5
  3. 예제 3

    입력
    9
    -4 -4
    -4 0
    -4 4
    0 -4
    0 0
    0 4
    4 -4
    4 0
    4 4
    예상 출력
    8