A11239 | Polycarp's phone book
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from $0$ . All the numbers are distinct.
There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which there is a substring equal to the entered sequence of digits. For example, is there are three phone numbers in Polycarp's contacts: $123456789$ , $100000000$ and $100123456$ , then:
- if he enters $00$ two numbers will show up: $100000000$ and $100123456$ ,
- if he enters $123$ two numbers will show up $123456789$ and $100123456$ ,
- if he enters $01$ there will be only one number $100123456$ .
For each of the phone numbers in Polycarp's contacts, find the minimum in length sequence of digits such that if Polycarp enters this sequence, Berdroid shows this only phone number.
There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which there is a substring equal to the entered sequence of digits. For example, is there are three phone numbers in Polycarp's contacts: $123456789$ , $100000000$ and $100123456$ , then:
- if he enters $00$ two numbers will show up: $100000000$ and $100123456$ ,
- if he enters $123$ two numbers will show up $123456789$ and $100123456$ ,
- if he enters $01$ there will be only one number $100123456$ .
For each of the phone numbers in Polycarp's contacts, find the minimum in length sequence of digits such that if Polycarp enters this sequence, Berdroid shows this only phone number.
输入格式
The first line contains single integer $n$ ( $1<=n<=70000$ ) — the total number of phone contacts in Polycarp's contacts.
The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from $1$ to $9$ . All the numbers are distinct.
The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from $1$ to $9$ . All the numbers are distinct.
输出格式
Print exactly $n$ lines: the $i$ -th of them should contain the shortest non-empty sequence of digits, such that if Polycarp enters it, the Berdroid OS shows up only the $i$ -th number from the contacts. If there are several such sequences, print any of them.
输入输出样例
输入 #1
3 123456789 100000000 100123456
输出 #1
9 000 01
输入 #2
4 123456789 193456789 134567819 934567891
输出 #2
2 193 81 91
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted