Polish version    English version  
  History of OI -> XI OI 2003/2004 -> Problems


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
Schedule
Problems
Stage III - results
Stage II - results
Stage I - results
Stage II
Stage III
Rules
For contestants
Helpful resources
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
XI Olimpiad in Informatics 2003/2004

Task: WYS

The Islands

III stage competition, day I  
Source file: wys.*
Memory limit: 32 MB

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 there are 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.

Task

Write a programme which:

  • reads from the standard input a description of the coastlines of islands and lakes,
  • calculates the maximum degree of island/lake,
  • writes the results to standard output.

Input

In the first line there is one integer n, the number of coastlines, 1 <= n <= 40000. The coastlines are described in the following lines, a single coastline per line. Each of the lines 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 <= 10000. Next there are k numbers: x1, x2, ..., xk, 0 <= xi <= 108. The points forming the coastline are (x1, x2), (x3, x2), (x3, x4), (x5, x4), ... (xk-1, xk), (x1, xk). They are given in the 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.

Output

Your programme should write in the first and only line a single integer - the maximum degree of island/lake.

Example

For the input data:

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
the correct result is:
5



Print friendly version