QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#15774. Triangle Covering Problem

Statistics

In a two-dimensional plane, you are given $N$ isosceles right triangles (each triangle has its two legs parallel to the coordinate axes, and the hypotenuse runs from top-left to bottom-right). We describe such a triangle using three non-negative integers $(x, y, d)$, where the coordinates of the three vertices of the triangle are $(x, y)$, $(x + d, y)$, and $(x, y + d)$. Calculate the total area covered by these $N$ triangles. For example, the figure below shows 3 triangles, and the total covered area is $11.0$.

Input

The first line contains a positive integer $N$, representing the number of triangles. Each of the following $N$ lines contains three space-separated non-negative integers $x, y, d$, describing the vertex coordinates of a triangle as $(x, y)$, $(x + d, y)$, and $(x, y + d)$, where $0 \le x, y, d \le 1000000$. For 50% of the data, $1 \le N \le 500$; for 100% of the data, $1 \le N \le 10000$.

Output

Output a single line containing a real number $S$, representing the total area covered by all triangles, rounded to exactly one decimal place. The input data guarantees $S \le 2^{31}$.

Examples

Input 1

3
1 1 4
2 0 2
3 2 2

Output 1

11.0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.