Under construction

Still being built. Things may change

XOR Shapes

Time limit1sMemory limit128 MB

Summary
Given up to 10 right isosceles triangles drawn with XOR-style color inversion, compute the total black area after all draws.
Level

Medium6 of 10

Topics
Geometry, Bit manipulation, Brute force
Solved
No attempts yet

Problem

At first the entire sketchbook is white. On it you draw N right isosceles triangles one after another.

Each triangle has its bottom-left vertex at (X, Y) and both legs of length R. In other words, the region covered by a single triangle is the set of all points (x, y) satisfying x >= X, y >= Y, and x + y <= X + Y + R.

Every time a triangle is drawn, all colors inside it are inverted: white areas become black and black areas become white.

After drawing all N triangles, find the area of the region that remains black.

Input

The first line contains the number of triangles N (1 <= N <= 10).

Each of the next N lines contains the information of one triangle: X, Y, R (1 <= X, Y, R <= 10^6). (X, Y) is the bottom-left vertex of the triangle and R is the length of each leg.

Output

Print the area of the black region with one digit after the decimal point.

Examples3

  1. Example 1

    Input
    3
    1 1 2
    7 1 6
    5 3 4
    
    Expected output
    24.0
    
  2. Example 2

    Input
    5
    5 5 99
    5 5 99
    5 5 99
    5 5 99
    5 5 99
    
    Expected output
    4900.5
    
  3. Example 3

    Input
    4
    5 5 99
    5 5 99
    5 5 99
    5 5 99
    
    Expected output
    0.0