P15840 [The 1st Lanqiao Cup International Contest] Material Cutting (No testdata yet)
Description
Material cutting is an important step in industrial manufacturing. To cut accurately, it usually requires programming to control the cutting machine. The control instructions of the cutting machine consist of many commands for drawing straight lines, and each command can cut a line segment on the material.
As the engineer of the cutting machine, Xiaoming wants to know: after executing a series of control instructions, what is the total area of the parts cut off from the material. During the cutting process, it is guaranteed that no three line segments share a common point.
Input Format
The first line contains an integer $n$, indicating the number of control instructions.
The next $n$ lines each contain $4$ integers $x_1, y_1, x_2, y_2$, describing one control instruction. This instruction means cutting a straight line segment between $(x_1, y_1)$ and $(x_2, y_2)$.
Output Format
Output one line containing a real number, rounded to two digits after the decimal point, representing the area of the parts cut off from the material.
Note that the cut-off part may not be a single whole piece. Some cutting instructions, after being executed, will not cause the cut part to fall off from the material. Only those parts that are completely separated from the material will be counted as cut off.
Explanation/Hint
### Constraints
For $10\%$ of the test cases, $n \le 4$.
For $30\%$ of the test cases, $n \le 10$.
For $50\%$ of the test cases, $n \le 50$.
For $70\%$ of the test cases, $n \le 100$.
For all test cases, $1 \le n \le 300$, $1 \le x_1, y_1, x_2, y_2 \le 1000$, and no three line segments share a common point.
Translated by ChatGPT 5