Islands islands.X
Byteotia is an island surrounded by ocean. There are lakes in Byteotia. On
these lakes there are isles which themselves contain lakes on which in turn
contain further isles and so on. The ocean has degree 0. Byteotia has
degree 1. The lakes situated on the Byteotian Isles have degree 2 etc., so
a lake has degree w+1 if it is situated on an island of degree w and and
island has a degree j+1 if it lies on a lake of degree j. It follows that
the degrees of all islands are odd whereas the degrees of lakes and the
ocean are always even. All lakes and islands have coastlines in shape of
polygons whose each edge is perpendicular to its neighbours (the edges are
parallel to the axes OX, OY) and their vertices have integer coordinates.
No two coastlines meet or intersect. Having been given the contours of the
coastlines, calculate the maximum degree of lake/island in Byteotia.
Thus, your program should
* reads from stdin a description of the coastlines of islands and lakes,
* calculate the maximum degree of an island/lake,
* writes the results to stdout
PROBLEM NAME: islands.X
INPUT FORMAT:
* Line 1: A single integer N (1 <= N <= 40,000): the number of coastlines.
* Lines 2..N+1: Each of the lines describes a single coastline and
contains nonnegative integers separated by single spaces. The
first number in each line, K, signifies the even number of
points comprising the coastline (4 <= K <= 10,000). Next there
are K numbers: x_1, x_2, ..., x_K (0 <= x_i <= 100,000,000).
The points forming the coastline are (x_1, x_2), (x_3, x_2),
(x_3, x_4), (x_5, x_4), ... (x_K-1, x_K), (x_1, x_K). They are
given in Cartesian coordinates and anticlockwise (so while
going from i to i+1 we always have the interior on the left
side). The coastlines are given in such order that:
* the coastline of each lake is given after the coastline of the island it
is situated on,
* the coastline of each island is given after the coastline of the lake it
is situated on.
To describe the whole map no more than 200,000 points have been used.
SAMPLE INPUT:
6
4 1 0 17 12
16 10 4 16 11 2 4 8 2 3 3 2 1 16 3 15 2
8 8 10 3 5 12 8 11 6
6 10 9 15 10 9 7
4 4 6 7 9
4 6 8 5 7
OUTPUT FORMAT:
* Line 1: A single integer: the maximum degree of an island/lake.
SAMPLE OUTPUT:
5