当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1371:Tin Cutter

题目描述
In a Tin Cutting factory there is a machine for cutting parts from tin plates. It has an extraordinarily sharp knife able to make horizontal or vertical segment cuts in the tin plates. Each cutting process consists of a sequence of such cuts. Each segment cut is given by its endpoints that are always located inside the tin plate. During the cutting process some parts of tin plate can fall out and so some holes in the plate can emerge.
Factory management needs to predict the number of holes in the plate at the end of the given sequence of cuts. Write a program that answers this question. Single segment cuts are not considered to be holes.

Here there are examples of some situations that can arise after cutting:


  two holes         two holes          one hole             one hole


输入解释
The input consists of blocks of lines. Each block except the last describes one cutting process. In the first line of the block there is a number N <= 100 indicating the number of segment cuts in the cutting process. These cuts are defined by the following N lines. The line defining one segment cut has the form X1 Y1 X2 Y2 where X1 Y1 and X2 Y2 are the co-ordinates of the end points of the segment cut. They are separated by one space. The co-ordinates are integers and always define horizontal or vertical segment (i.e. segment parallel with x or y axis).

The last block consists of just one line containing 0.
输出解释
The output contains the lines corresponding to the blocks in the input. Each such line contains the number of holes that remain in the tin plate after the execution of the corresponding cuts.

There is no line in the output corresponding to the last ``null'' block of the input.
输入样例
4
0 1 1 1
1 1 1 0
1 0 0 0
0 0 0 1
2
0 1 2 1
1 2 1 0
0
输出样例
1
0

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Central Europe 1996

源链接: POJ-1371

最后修改于 2020-10-29T06:02:10+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000