A8555 | Phone Code
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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
A prefix of string $t$ is a string that is obtained by deleting zero or more digits from the end of string $t$ . For example, string "00209" has 6 prefixes: "" (an empty prefix), "0", "00", "002", "0020", "00209".
In the first sample the city phone code is string "00".
In the second sample the city phone code is an empty string.
In the third sample the city phone code is string "770123456789".
In the first sample the city phone code is string "00".
In the second sample the city phone code is an empty string.
In the third sample the city phone code is string "770123456789".
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted