P4196 【Template】Half-Plane Intersection / [CQOI2006] Convex Polygon

Description

Given $n$ convex polygons with vertices listed in counterclockwise order, find the area of their intersection. For example, when $n = 2$, the two convex polygons are shown below: ![](https://cdn.luogu.com.cn/upload/image_hosting/7ieux7g3.png) The area of the intersection is $5.233$.

Input Format

The first line contains an integer $n$, the number of convex polygons. Each polygon is then described in order. For the $i$-th polygon, the first line contains an integer $m_i$, the number of edges. The next $m_i$ lines each contain two integers, giving the coordinates of the vertices in counterclockwise order.

Output Format

Output a single real number, the area of the intersection, rounded to three decimal places.

Explanation/Hint

Constraints: For $100\%$ of the testdata: $2 \leq n \leq 10$, $3 \leq m_i \leq 50$, and each coordinate is an integer in $[-1000, 1000]$. Translated by ChatGPT 5