#P1299. 切孔机
切孔机
Description
Assistants at the headquarters often need to cut holes of various shapes in a large sheet of paper. They have just purchased a new hole cutting machine, which is much more convenient and flexible than the one they used before. They want to write a program to determine what happens after a sequence of complex cuts; in particular, they want to know how many holes are formed in the paper.
The figure below shows several patterns formed after cutting.

Input Format
The first line contains an integer , the number of cutting operations, with . Each of the next lines gives one precise cut, described by four space-separated integers , with . Here, and are the coordinates where the cut starts, and and are the coordinates where the cut ends. You may assume all cutting points lie on the paper and never go out of bounds. Each cut is an axis-aligned segment (parallel to the or axis).
Output Format
Output a single integer on one line, the number of separate holes on the paper after all cuts are completed. Note that the area of any hole is at least square unit.
4
0 1 1 1
1 1 1 0
1 0 0 0
0 0 0 1
1
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号