当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
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:
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, y ∈ Z 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
时间上限 | 内存上限 |
1000 | 65536 |