QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#11885. The Islands

統計

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 i+1 if it is situated on an island of degree i and and island has a degree l+1 if it lies on a lake of degree l. 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 ≤ 40\,000$. The coastlines are described in the following lines, a single coastline per line. Each of the lines contains non-negative 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,\ldots,x_k$, $0 ≤ x_i ≤ 10^8$. 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 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

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

5
problem_11885_1.png
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.