#P3099. Cow Curling: Capturing Stones
Cow Curling: Capturing Stones
Cow Curling: Capturing Stones
Cow curling is a popular cold-weather sport played in the Moolympics. In this game, two teams each slide N heavy stones across a sheet of ice. At the end of the match, there will be 2N stones at distinct 2D coordinates.
A stone is considered "captured" if it lies inside or on the boundary of a triangle formed by any three stones belonging to the opponent. It can be shown that the union of all such triangles is exactly the convex hull of the opponent's stones. Therefore, the final score for a team is simply the number of the opponent's stones that lie inside or on the boundary of its convex hull.
Your task is to compute the final scores given the positions of all stones.
Note: All formulas are given in LaTeX format. For example, the cross product is defined as \( \text{cross}(O, A, B)= (A_x-O_x)(B_y-O_y)-(A_y-O_y)(B_x-O_x) \).
inputFormat
The first line contains an integer N (\(3 \le N \le 50000\)), representing the number of stones each team has.
The next N lines each contain two space-separated integers \(x\) and \(y\), giving the coordinates of Team A's stones.
This is followed by another N lines, each with two space-separated integers \(x\) and \(y\), representing the coordinates of Team B's stones.
outputFormat
Output two integers separated by a space. The first integer is the number of Team B's stones captured by Team A (i.e. the number of Team B stones lying inside or on the boundary of the convex hull of Team A's stones), and the second integer is the number of Team A's stones captured by Team B.
sample
3
0 0
0 2
2 0
1 1
1 3
3 1
3 1