300899: CF172A. Phone Code
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:2
Solved:0
Description
Phone Code
题意翻译
有 N(1< N < 30001) 个长度在(1——20)个字符的电话号码,求最大的 k ,使得 N 个电话号码的前 k 位完全相同题目描述
Polycarpus has $ n $ friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings $ s_{1},s_{2},...,s_{n} $ . All these strings consist only of digits and have the same length. Once Polycarpus needed to figure out Tarasov city phone code. He assumed that the phone code of the city is the longest common prefix of all phone numbers of his friends. In other words, it is the longest string $ c $ which is a prefix (the beginning) of each $ s_{i} $ for all $ i $ ( $ 1<=i<=n $ ). Help Polycarpus determine the length of the city phone code.输入输出格式
输入格式
The first line of the input contains an integer $ n $ ( $ 2<=n<=3·10^{4} $ ) — the number of Polycarpus's friends. The following $ n $ lines contain strings $ s_{1},s_{2},...,s_{n} $ — the phone numbers of Polycarpus's friends. It is guaranteed that all strings consist only of digits and have the same length from $ 1 $ to $ 20 $ , inclusive. It is also guaranteed that all strings are different.
输出格式
Print the number of digits in the city phone code.
输入输出样例
输入样例 #1
4
00209
00219
00999
00909
输出样例 #1
2
输入样例 #2
2
1
2
输出样例 #2
0
输入样例 #3
3
77012345678999999999
77012345678901234567
77012345678998765432
输出样例 #3
12