P5976 [CEOI 2008] Dominance

Description

A rectangle with width $W$ and height $H$ is given. There are two types of points on it: $black$ and $white$. Each point has its own radiation range. For any other point, if it receives more radiation from white points than from black points, it becomes a white point; otherwise, it becomes a black point. If the amounts are equal, it is neutral. Given the coordinates and radiation ranges of all white and black points, find how many white points and how many black points there will be in the end.

Input Format

The first line contains $W$ and $H$. The bottom-left corner is $(0,0)$, and the top-right corner is $(W-1,H-1)$. The second line contains an integer $N$, the number of points. The next $N$ lines each contain, in order: the point’s type, its coordinates, and its radiation range (in $[0, 5\times 10^8)$).

Output Format

Output two numbers: the number of white points and the number of black points, respectively.

Explanation/Hint

For $100\%$ of the testdata, $1 \le W,H \le 10^9$, $0 \le N \le 3\times 10^3$. ----- ### Sample Explanation: ![](https://cdn.luogu.com.cn/upload/image_hosting/hfu3bgfx.png) Translated by ChatGPT 5