#P4750. [CERC2017] Lunar Landscape

[CERC2017] Lunar Landscape

题目描述

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 nn 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)(x, y) of the square’s middle point and the length of its side aa — always an even integer.
  • Photos of type B have sides at a 4545^{\circ} angle to the coordinate axes. Such a photo is specified by giving the integer coordinates (x,y)(x, y) of the square’s middle point and the length of its diagonal dd — always an even integer.

Find the total surface area captured in the satellite photos.

输入格式

The first line contains an integer n(1n200000)n(1 \le n \le 200 000) — the number of photos. The jthj-th of the following nn lines is either of the form “A xj yj ajA \ x_j \ y_j \ a_j” or “B xj yj djB \ x_j \ y_j \ d_j” representing a photo of type A or B,respectively.

The xjx_j and yjy_j are the integer coordinates of the middle point of the photo (1000xj,yj1000)(-1 000 \le x_j, y_j \le 1 000). The aja_j and djd_j are even integers (2aj,dj1000)(2 \le a_j, d_j \le 1 000) — the side length and the diagonal length, respectively.

输出格式

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).

2
A 0 0 2
B 1 0 2
5.00
8
A -7 10 4
B 3 10 8
A -6 6 6
A -2 5 8
B 3 -1 8
B -7 -4 8
A 3 9 2
B 8 6 6

205.50