#P16894. [GKS 2022 #G] Curling

[GKS 2022 #G] Curling

Problem Description

20222022 is a year of the Winter Olympics! Curling has been one of the most popular winter sports as it requires skill, strategy, and sometimes a bit of luck.

In a curling game, 22 teams compete by sliding heavy granite stones on a long ice sheet. We call the teams the red team and the yellow team, as their stones are usually distinguished by the red and the yellow handle color. A curling game consists of several ends (subgames); in every end, the teams, each owning 88 stones, take turns to slide them across the long ice sheet toward a circular target area called the house. A stone may hit existing stones to change its own moving direction and other stones' position (including knocking them out of play). Roughly speaking, the goal for a team is to make their stones as close to the center of the house as possible.

Geometrically, a house and a stone can be modeled as a circle and a disk (the region bounded by a circle), respectively, and the scoring rules at the conclusion of each end are formally summarized as follows.

  • Each stone can be viewed as a disk of radius RsR_s on a 22-dimensional plane.
  • The house is a circle of radius RhR_h centered at (0,0)(0,0).
  • Only stones in the house are considered in the scoring. A stone is in the house if any portion of the stone lies on or within the circle representing the house. Tangency also counts.
  • A team is awarded 11 point for each of their own stones in the house such that no opponent's stone is closer (in Euclidean distance) to the center than it. We assume in this problem that no two stones are equally close to the center (0,0)(0,0).

22 teams are playing and have just delivered all their stones. The red team has NN stones remaining on the curling sheet, centered at (X1,Y1),(X2,Y2),,(XN,YN)(X_1, Y_1), (X_2, Y_2), \ldots, (X_N, Y_N), while the yellow team has MM stones remaining, centered at (Z1,W1),(Z2,W2),,(ZM,WM)(Z_1, W_1), (Z_2, W_2), \ldots, (Z_M, W_M). Now you are asked to figure out the scores of both teams.

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case begins with a line containing the two space-separated integers RsR_s and RhR_h.

The next line contains the integer NN. Then NN lines follow, the ii-th line of which containing the two space-separated integers XiX_i and YiY_i.

After that, similarly, the next line contains the integer MM. In the next MM lines, the ii-th line contains the two space-separated integers ZiZ_i and WiW_i.

Output Format

For each test case, output one line containing Case #x: y z, where xx is the test case number (starting from 11), yy is the score of the red team, and zz is the score of the yellow team.

2
1 5
4
1 -1
6 1
0 6
-5 0
0
10 100
2
-3 -4
200 200
0
Case #1: 3 0
Case #2: 1 0
2
1 5
2
1 0
-3 0
1
0 2
10 50
2
-40 -31
-35 70
3
59 0
-10 0
30 40
Case #1: 1 0
Case #2: 0 2

Hint

In this case, the yellow team has no stones left in the house, so the red team receives a point for each of their stone in the house. All the existing stones are in the house except the one centered at (6,1)(6, 1) (it would have touched the house boundary if it were centered at (6,0)(6, 0)), so the red team gets 33 points.

In the additional case, both teams have stones inside the house. The red stone at (1,0)(1, 0) is in the house and no yellow stone is closer than it to the center of the house, so it is worthy of a point.

Although the other red stone (centered at (3,0)(-3, 0)) is also in the house, it is not worthy of a point because the yellow stone centered at (0,2)(0, 2) is closer than it to the center (0,0)(0, 0). The yellow stone is not worthy of a point, either, due to the existence of the red stone at (1,0)(1, 0). Therefore, the red team gets 11 point and the yellow team gets 00 points.

Limits

1T1001 \le T \le 100.

1Rs<Rh1041 \le R_s < R_h \le 10^4.

0N80 \le N \le 8.

2×104Xi2×104-2 \times 10^4 \le X_i \le 2 \times 10^4, for all ii.

2×104Yi2×104-2 \times 10^4 \le Y_i \le 2 \times 10^4, for all ii.

2×104Zi2×104-2 \times 10^4 \le Z_i \le 2 \times 10^4, for all ii.

2×104Wi2×104-2 \times 10^4 \le W_i \le 2 \times 10^4, for all ii.

The distances between the center of each stone and the center of the house (0,0)(0, 0) are distinct, i.e., no two stones are equally close to the center of the house.

No two stones overlap (but two stones can be tangent).

Test Set 11

M=0M = 0.

Test Set 22

0M80 \le M \le 8.