#P8785. [蓝桥杯 2022 省 B] 扫雷

[蓝桥杯 2022 省 B] 扫雷

Problem Description

Xiaoming has recently become obsessed with a game called Minesweeper. In one level, the task is as follows: on a 2D plane, there are nn mines. The ii-th mine (xi,yi,ri)(x_{i}, y_{i}, r_{i}) means there is a mine at coordinates (xi,yi)(x_{i}, y_{i}), and its blast range is a circle with radius rir_{i}.

To safely pass through this land, the player needs to clear mines. The player can launch mm mine-clearing rockets. Xiaoming has already planned the launch direction of each rocket. The jj-th rocket (xj,yj,rj)(x_{j}, y_{j}, r_{j}) means this rocket will explode at (xj,yj)(x_{j}, y_{j}), and its blast range is a circle with radius rjr_{j}. Any mine within its blast range will be detonated. At the same time, when a mine is detonated, any mines within its blast range will also be detonated. Now Xiaoming wants to know how many mines in total are detonated this time.

You may treat both mines and mine-clearing rockets as points on the plane. Multiple mines and rockets may exist at the same point. A mine located on the boundary of a blast range will also be detonated.

Input Format

The first line contains two integers nn and mm.

The next nn lines each contain three integers xi,yi,rix_{i}, y_{i}, r_{i}, describing a mine.

The following mm lines each contain three integers xj,yj,rjx_{j}, y_{j}, r_{j}, describing a mine-clearing rocket.

Output Format

Output one integer, the answer.

2 1
2 2 4
4 4 2
0 0 5
2

Hint

[Sample Explanation]

The sample diagram is as follows. Rocket 1 covers mine 1, so mine 1 is detonated. Mine 1 also covers mine 2, so mine 2 is also detonated.

[Constraints]

For 40%40\% of the testdata: $0 \leq x, y \leq 10^{9}, 0 \leq n, m \leq 10^{3}, 1 \leq r \leq 10$.

For 100%100\% of the testdata: $0 \leq x, y \leq 10^{9}, 0 \leq n, m \leq 5 \times 10^{4}, 1 \leq r \leq 10$.

Lanqiao Cup 2022 Provincial Contest B Group, Problem H.

Translated by ChatGPT 5