Under construction

Still being built. Things may change

Convex Hull

Time limit1sMemory limit1024 MB

Summary
For each point, count how many of the other points lie on the convex hull after that point is removed from the set.
Level

Hard8 of 10

Topics
Geometry, Sorting, Implementation
Solved
No attempts yet

Problem

The convex hull of a 2-dimensional point set PP is the polygon with the smallest perimeter that encloses all points in PP. It is called convex because the polygon always has a convex shape.

You are given a set PP of NN points. For each point (xi,yi)∈P(x_i, y_i) \in P, output the number of points in P∖{(xi,yi)}P \setminus \{(x_i, y_i)\} that lie exactly on the convex hull of P∖{(xi,yi)}P \setminus \{(x_i, y_i)\}. In other words, point (xi,yi)(x_i, y_i) is removed from PP before the hull is built. The hull can degenerate into a line segment or a single point, depending on the points.

Input

The first line contains an integer NN (2≤N≤1000002 \le N \le 100000), the number of points in PP. Each of the next NN lines contains two integers xix_i and yiy_i (−109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9), the coordinates of the iith point. No two points share the same coordinates.

Output

Print NN lines. The iith line contains the number of points in P∖{(xi,yi)}P \setminus \{(x_i, y_i)\} that lie exactly on the convex hull of P∖{(xi,yi)}P \setminus \{(x_i, y_i)\}.

Examples2

  1. Example 1

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

    Input
    3
    0 0
    0 100
    100 0
    
    Expected output
    2
    2
    2