#P4023. [CTSC2012] 极点统计

[CTSC2012] 极点统计

Description

For a set SS of points in the plane and a point pp in the plane, define the function f(p,S)f(p, S) to be 11 if and only if pp lies inside the convex hull of SS (including its boundary), and 00 otherwise.

Given two sets of points in the plane P={p1,p2,,pN}P=\{p_1,p_2,\cdots,p_N\} and A={a1,a2,,aM}A=\{a_1,a_2,\cdots,a_M\}, we call a point aiAa_i \in A an extreme point if and only if

jif(ai,P{aj})=0.\sum_{j\ne i} f(a_i,P\cup\{a_j\})=0.

That is, aia_i is not inside the convex hull formed by PP together with any other single point from AA.

Please count the number of extreme points in set AA.

Input Format

  • The first line contains two space-separated positive integers NN and MM.
  • The second line contains NN space-separated pairs of integers; the ii-th pair (xip,yip)(x_i^p,y_i^p) denotes the coordinates of point pip_i.
  • The third line contains MM space-separated pairs of integers; the jj-th pair (xja,yja)(x_j^a,y_j^a) denotes the coordinates of point aja_j.
  • For the same set, the input guarantees that no two points share identical coordinates.

Output Format

Output a single line with a single integer, the number of extreme points in set AA.

4 5 
6 3 7 -1 -6 -5 1 5
-5 -5 7 -5 9 -9 -10 11 -5 -6
3

Hint

Constraints:

  • For 30%30\% of the testdata, N,M50N,M\le 50.
  • For another 30%30\% of the testdata, N10,M20000N\le 10, M\le 20000.
  • For 100%100\% of the testdata, $3\le N\le 10^5, 1\le M\le 10^5,\ |x_i|,|y_i|\le 10^6$, and the convex hull of set PP has non-zero area.

Translated by ChatGPT 5