P4750 [CERC2017] Lunar Landscape

Description

A satellite is surveying a possible rover landing area on the moon. The landing area is modeled as a square grid embedded in the standard coordinate system. The satellite has taken $n$ photos, each capturing a square area of the surface. Careful camera calibration has ensured that all photos are aligned with the grid — all four vertices have integer coordinates. Due to the satellite’s changing orbit there are two types of photos: - Photos of type ``A`` have sides that are parallel to coordinate axes. Such a photo is specified by giving the integer coordinates $(x, y)$ of the square’s middle point and the length of its side $a$ — always an even integer. - Photos of type ``B`` have sides at a $45^{\circ}$ angle to the coordinate axes. Such a photo is specified by giving the integer coordinates $(x, y)$ of the square’s middle point and the length of its diagonal $d$ — always an even integer. Find the total surface area captured in the satellite photos.

Input Format

The first line contains an integer $n(1 \le n \le 200 000)$ — the number of photos. The $j-th$ of the following $n$ lines is either of the form “$A \ x_j \ y_j \ a_j$” or “$B \ x_j \ y_j \ d_j$” representing a photo of type ``A`` or ``B``,respectively. The $x_j$ and $y_j$ are the integer coordinates of the middle point of the photo $(-1 000 \le x_j, y_j \le 1 000)$. The $a_j$ and $d_j$ are even integers $(2 \le a_j, d_j \le 1 000)$ — the side length and the diagonal length, respectively.

Output Format

Output a number with exactly two digits after the decimal point — the total area of the surface. The answer has to exactly correspond to the judge’s solution (no rounding errors are tolerated).