#P15840. [蓝桥杯第一届国际赛] 材料切割

    ID: 19913 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>计算几何2017蓝桥杯国赛

[蓝桥杯第一届国际赛] 材料切割

Problem 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 nn, indicating the number of control instructions.

The next nn lines each contain 44 integers x1,y1,x2,y2x_1, y_1, x_2, y_2, describing one control instruction. This instruction means cutting a straight line segment between (x1,y1)(x_1, y_1) and (x2,y2)(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.

5
9 5 2 3
4 6 3 3
2 5 2 9
4 3 2 8
3 0 1 7
0.33

Hint

Constraints

For 10%10\% of the test cases, n≤4n \le 4.

For 30%30\% of the test cases, n≤10n \le 10.

For 50%50\% of the test cases, n≤50n \le 50.

For 70%70\% of the test cases, n≤100n \le 100.

For all test cases, 1≤n≤3001 \le n \le 300, 1≤x1,y1,x2,y2≤10001 \le x_1, y_1, x_2, y_2 \le 1000, and no three line segments share a common point.

Translated by ChatGPT 5