CF858D.Polycarp's phone book
普及/提高-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
Polycarp 的手机通讯录中有 n 个电话号码。每个号码是一个 9 位整数,且首位数字不为 0。所有号码互不相同。
Polycarp 的手机上安装了最新版本的 Berdroid 操作系统。当用户输入一串数字时,系统会显示通讯录中所有包含该数字串作为子串的电话号码。例如,若 Polycarp 的通讯录中有三个电话号码:123456789、100000000 和 100123456,则:
- 若他输入
00,将显示两个号码:100000000和100123456; - 若他输入
123,将显示两个号码:123456789和100123456; - 若他输入
01,将只显示一个号码:100123456。
对 Polycarp 通讯录中的每个电话号码,请找出长度最短的一串数字,使得当 Polycarp 输入该串时,Berdroid 系统仅显示该电话号码(即该数字串是该号码的子串,但不是其他任何号码的子串)。
输入格式
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.
第一行包含一个整数 n(1≤n≤70000)—— 表示 Polycarp 通讯录中电话联系人的总数。
随后是 n 个电话号码,每行一个。每个号码是一个 9 位正整数,且首位数字为 1 至 9 中的一个。所有号码互不相同。
输出格式
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.
恰好输出 n 行:其中第 i 行应包含最短的非空数字序列,使得 Polycarp 输入该序列后,Berdroid 操作系统仅显示联系人列表中的第 i 个号码。若存在多个满足条件的序列,则输出其中任意一个即可。
输入输出样例
输入#1
3 123456789 100000000 100123456
输出#1
9 000 01
输入#2
4 123456789 193456789 134567819 934567891
输出#2
2 193 81 91
输入解题思路,AI测评打分。不知道怎么写?