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

建议使用的浏览器:

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

3354:Connect the Dots

题目描述

Given a rectangular region of the plane which has been divided into polygons, decide what the maximum number of edges that any of the polygons has. For example, if the region is divided into triangles, then the maximal number is 3. If the region is divided into, say, 7 triangles and 2 squares, then the maximal number is 4.

There will be a list of pairs of (x, y) coordinates: Each (x, y) coordinates represents a vertex, and consequently each pair of coordinates represents an edge. The edges collectively divide the rectangular region naturally into disjoint ``n-gons". (Explanation: A triangle is a 3-gon, a square is an example of a 4-gon, etc.) That is, the boundary of each n-gon is a union of edges.

Figure 1 is a sketch of an example 3 x 3 rectangular region divided into five 3-gons, a 5-gon and a 10-gon.

The pairs of coordinates representing the edges of the 5-gon would be:

{((3, 4),(4, 4)),((4, 4),(4, 3)),((3, 4),(3, 3)),((3, 3),(4, 2)),((4, 3),(4, 2))}

The maximal number of edges in this example is 10. That is, this example has a 10-gon.

输入解释

The input consists of multiple test cases. The first line of each test case will consist of an integer n representing the number of edges. Each test case will then contain n pairs of (x, y) (|x|, |y| ≤ 100) coordinates where x, yZ which represent edges dividing a rectangular region into n-gons. Each integer will be separated by a white space. Overlapping edges will not be specified in the input. The input will terminate for n = 0.

输出解释

The output should be an integer describing the maximal number of edges that any of those n-gon has. Separate each test case with a new line.

输入样例
21 
1 1 1 2 
1 2 1 3 
1 3 1 4 
1 1 2 1 
2 1 3 1 
3 1 4 1 
1 4 2 4 
2 4 3 4 
3 4 4 4 
4 1 4 2 
4 2 4 3 
4 3 4 4 
2 3 2 4 
2 3 3 4 
2 3 3 3 
3 3 3 4 
3 3 4 2
2 1 3 2 
3 2 3 1 
4 1 3 2 
3 2 4 2 
0
输出样例
10

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

题目来源 Manila 2006

源链接: POJ-3354

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

共提交 0

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