Magic Triangles

반시계 방향으로 주어진 N개의 삼각형에 대해 모든 삼각형의 공통 교집합 넓이를 구한다.

어려움8기하구현분할 정복완전 탐색아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Fallen angel Yohane plans to draw a magic symbol composed of triangles on the earth. By casting some magic spell on the symbol, she will obtain magic power; this is the purpose for which she will draw a magic symbol. The magic power yielded from the magic symbol is determined only by the common area of all the triangles. Suppose the earth is a two-dimensional plane and the vertices of the triangles are points on the plane. Yohane has already had a design of the magic symbol, i.e. the positions, sizes, shapes of the triangles. However, she does not know how much magic power will be obtained from the symbol. Your task as a familiar of the fallen angel is to write a program calculating the common area of given triangles on a two-dimensional plane.

입력

The input consists of a single test case in the following format.

$N$
$x_{1,1}$ $y_{1,1}$ $x_{1,2}$ $y_{1,2}$ $x_{1,3}$ $y_{1,3}$
...
$x_{N,1}$ $y_{N,1}$ $x_{N,2}$ $y_{N,2}$ $x_{N,3}$ $y_{N,3}$

The first line contains an integer NN, which is the number of triangles (1N1051 \le N \le 10^5). The ii-th line of the following NN lines contains six integers x_i,1x\_{i,1}, y_i,1y\_{i,1}, x_i,2x\_{i,2}, y_i,2y\_{i,2}, x_i,3x\_{i,3}, and y_i,3y\_{i,3}, where (x_i,j,y_i,j)(x\_{i, j}, y\_{i, j}) is the coordinate of the jj-th vertex of the ii-th triangle (1,000x_i,j,y_i,j1,000-1{,}000 \le x\_{i, j}, y\_{i, j} \le 1{,}000).

You can assume the followings:

  • Every triangle has a positive area.
  • The vertices of every triangle are in the counter-clockwise order.

출력

Output the common area of given triangles in a line. The output can contain an absolute or relative error no more than 10610^{−6}.