La umbra nucului bătrân

Time limit: 1s Memory limit: 256MB Input: Output:

"La umbra nucului bătrân
Pe banca învechită"

You are living in a 3D world, so, since we want to have problems with real-life applications, we will give you a 3D geometry problem.

To simplify things, we say that the world is a cuboid and everything in the world has xx and yy coordinates in the interval [100,100][-100, 100] and zz coordinates in the interval [1,100][1, 100] (since below zero you are underground). We will also assume that the clouds can completely stop the light.

The sun emits parallel rays directed along the zz-axis. Its light goes straight down.

Now that we have established this, I'm going to tell you the problem.

Task

There are nn clouds in the sky. A cloud can be seen as a convex polygon with integer coordinates, with its vertices having the same zz coordinate. You want to compute the total area of the shadow visible on the ground and on other clouds.

Input data

The first line contains a single integer nn. On the following lines, the clouds are described in the following way:

  • On the first line, there is viv_i representing the number of vertices describing the ii-th cloud.
  • On the following viv_i lines, there are 3 integers xx, yy, and zz, the vertices of the cloud, given in counter-clockwise order.

Output data

Output a single value which represents the total area of the shadows. The answer will be considered correct if either the absolute or relative difference between your answer and the correct answer is less than 10610^{-6}.

Constraints and clarifications

  • 1n201 \le n \le 20
  • 3vi203 \le v_i \le 20
  • 100x,y100-100 \le x, y \le 100
  • 1z1001 \le z \le 100
  • For each cloud, all vertices have the same zz coordinate.
  • There are no two clouds with the same zz coordinate.

Example

stdin

2
4
0 0 5
2 0 5
2 2 5
0 2 5
4
1 1 8
3 1 8
3 3 8
1 3 8

stdout

8.00000

Explanation

The area of the shadow on the ground (made by both clouds) is 77, and the area of the shadow on the first cloud (made by the second cloud) is 11, for a total of 88.

Log in or sign up to be able to send submissions!