PHRASES - Relevant Phrases of Annihilation

题意翻译

# 题目描述 你是Byteotia国的国王,你的手下刚刚拦截一批敌国对你的岛屿的进攻的信息,这些信息被加密过。你马上把它寄给了Byteotia国的密码破译师,然而他正在忙于吃爆米花,所以他只会破译最重要的部分。 你决定找出这些文本中被敌国强调最多的片段。这个片段在每份信息中不重叠的出现过两次以上。你想为难您的破译师,所以请找到最长的片段。 # 输入格式 第一行是一个正整数$t(t \le 10)$表示数据组数。之后会有t组测试数据。 每组数据第一行是一个正整数$n(n \le 10)$,代表信息的数量,之后的n行,每行有一串小写字母。字母的个数大于$2$小于$15000$ # 输出格式 对于每组测试数据,输出最长的在每份信息中不重叠的出现过两次以上的片段 # 样例输入 1 4 abbabba dabddkababa bacaba baba # 样例输出 2

题目描述

You are the King of Byteland. Your agents have just intercepted a batch of encrypted enemy messages concerning the date of the planned attack on your island. You immedietaly send for the Bytelandian Cryptographer, but he is currently busy eating popcorn and claims that he may only decrypt the most important part of the text (since the rest would be a waste of his time). You decide to select the fragment of the text which the enemy has strongly emphasised, evidently regarding it as the most important. So, you are looking for a fragment of text which appears in all the messages disjointly at least twice. Since you are not overfond of the cryptographer, try to make this fragment as long as possible.

输入输出格式

输入格式


The first line of input contains a single positive integer t<=10, the number of test cases. t test cases follow. Each test case begins with integer n (n<=10), the number of messages. The next n lines contain the messages, consisting only of between 2 and 10000 characters 'a'-'z', possibly with some additional trailing white space which should be ignored.

输出格式


For each test case output the length of longest string which appears disjointly at least twice in all of the messages.

输入输出样例

输入样例 #1

1
4
abbabba
dabddkababa
bacaba
baba

输出样例 #1

2