#P2463. [SDOI2008] Sandy 的卡片

    ID: 1469 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2008各省省选山东KMP后缀数组,SA

[SDOI2008] Sandy 的卡片

Description

Sandy and Sue both love collecting cards from crispy noodle snacks.

However, Sue collects cards for the beautiful characters on them, while Sandy collects them to exchange for super cool character figures.

Each card is labeled with a sequence of numbers. The length of the sequence on the ii-th card is MiM_i. To redeem a character figure, you must first collect NN cards. For these NN cards, if they all share a common contiguous subarray of length kk, then you can redeem a figure of level kk. Identical means: two substrings have the same length, and adding a number to every element of one substring will make it equal to the other.

Sandy has far fewer cards than the required NN, so Sue decides to give her cards to Sandy for Sandy’s birthday. With Sue’s help, Sandy finally has NN cards. However, Sandy does not know which level of figure can be redeemed. Now, please help Sandy and Sue determine the highest level of figure they can get.

Input Format

The first line contains an integer NN, the minimum number of cards required to redeem a figure, i.e., the number of cards Sandy now has.

For each i=1,2,,Ni = 1, 2, \dots, N, the (i+1)(i+1)-th line starts with the length MiM_i of the ii-th card’s sequence, followed by MiM_i integers separated by spaces, where the jj-th number is the jj-th element in the sequence.

Output Format

Output a single integer kk, the maximum obtainable level.

2
2 1 2
3 4 5 9

2

Hint

30%30\% of the testdata guarantee n50n \le 50.

100%100\% of the testdata guarantee n1000,M1000,2Mi101n \le 1000, M \le 1000, 2 \le M_i \le 101.

Update: In the statement, the Constraints for MiM_i and MM are actually the same thing. True Constraints: 40n1000,2Mi10140 \le n \le 1000, 2 \le M_i \le 101, and each number in the sequences is in the range [0,1864][0, 1864].

Translated by ChatGPT 5