300632: CF120H. Brevity is Soul of Wit

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Brevity is Soul of Wit

题意翻译

# 题目描述 当我们交流的时候,我们能够学到很多新东西。 然而,交流的过程会消耗太多时间。 如果我们去看一下我们在日常交流中使用的词汇,事情就变得很清楚了。 我们可以列出很多由许多字母组成的简单的单词, 如“information”,“technologies”,“university”, “conservatoire”,“refrigerator”, “stopwatch”,“windowsill”,“electricity”, “government”等。当然,我们可以继续重复列出这样的词汇以至无穷。 幸运的是,这个问题的解决方案已经被找到了。 为了让我们的发言更加简洁明了, 我们应该用那些和这些最初的词汇相近的、但是更加短的单词来替代它们。 这个想法目前还没有被应用于实际生活, 而这正是你被选中来改变这个状况的原因。 让我们考虑下面这个变换单词的方式: 我们假设一个人在一场谈话中可以使用n个单词。 对于每个单词,我们引入一个概念:它的短变形。 对于任意一个单词s,我们定义它的短变形为t。 t需要满足如下条件: 1.它是s的子序列。 2.它的长度在1到4个字母之间。 换句话说,t包含至少一个,至多四个, 且在t中顺序与其在s中顺序相同的字母。 注意:t中的字母在s中并不是一个紧挨着一个出现的。 当原本的单词长度不超过4时,你不能再缩短它。 给出n个不同单词。你的任务是找出它们的短变形。 要求使得这些单词的短变形两两不同。 # 输入格式 输入文件的第一行只包含一个整数n。 接下来有n行,每行包含一个由小写字母组成的单词。 每个单词的长度不超过10。 # 输出格式 如果解决方案存在, 在输出文件中输出n行,第i行是输入文件中第i行 给出的单词的短变形。如果有不止一个满足条件的 短变形,输出其中任意一个。 如果不存在解决方案,输出-1。

题目描述

As we communicate, we learn much new information. However, the process of communication takes too much time. It becomes clear if we look at the words we use in our everyday speech. We can list many simple words consisting of many letters: "information", "technologies", "university", "construction", "conservatoire", "refrigerator", "stopwatch", "windowsill", "electricity", "government" and so on. Of course, we can continue listing those words ad infinitum. Fortunately, the solution for that problem has been found. To make our speech clear and brief, we should replace the initial words with those that resemble them but are much shorter. This idea hasn't been brought into life yet, that's why you are chosen to improve the situation. Let's consider the following formal model of transforming words: we shall assume that one can use $ n $ words in a chat. For each words we shall introduce a notion of its shorter variant. We shall define shorter variant of an arbitrary word $ s $ as such word $ t $ , that meets the following conditions: - it occurs in $ s $ as a subsequence, - its length ranges from one to four characters. In other words, the word $ t $ consists at least of one and at most of four characters that occur in the same order in the word $ s $ . Note that those characters do not necessarily follow in $ s $ immediately one after another. You are allowed not to shorten the initial word if its length does not exceed four characters. You are given a list of $ n $ different words. Your task is to find a set of their shortened variants. The shortened variants of all words from the list should be different.

输入输出格式

输入格式


The first line of the input file contains the only integer $ n $ $ (1<=n<=200) $ . Then $ n $ lines contain a set of different non-empty words that consist of lowercase Latin letters. The length of each word does not exceed $ 10 $ characters.

输出格式


If the solution exists, print in the output file exactly $ n $ lines, where the $ i $ -th line represents the shortened variant of the $ i $ -th word from the initial set. If there are several variants to solve the problem, print any of them. If there is no solution, print -1.

输入输出样例

输入样例 #1

6
privet
spasibo
codeforces
java
marmelad
normalno

输出样例 #1

pret
sps
cdfs
java
mama
norm

输入样例 #2

5
aaa
aa
a
aaaa
aaaaa

输出样例 #2

-1

Input

题意翻译

# 题目描述 当我们交流的时候,我们能够学到很多新东西。 然而,交流的过程会消耗太多时间。 如果我们去看一下我们在日常交流中使用的词汇,事情就变得很清楚了。 我们可以列出很多由许多字母组成的简单的单词, 如“information”,“technologies”,“university”, “conservatoire”,“refrigerator”, “stopwatch”,“windowsill”,“electricity”, “government”等。当然,我们可以继续重复列出这样的词汇以至无穷。 幸运的是,这个问题的解决方案已经被找到了。 为了让我们的发言更加简洁明了, 我们应该用那些和这些最初的词汇相近的、但是更加短的单词来替代它们。 这个想法目前还没有被应用于实际生活, 而这正是你被选中来改变这个状况的原因。 让我们考虑下面这个变换单词的方式: 我们假设一个人在一场谈话中可以使用n个单词。 对于每个单词,我们引入一个概念:它的短变形。 对于任意一个单词s,我们定义它的短变形为t。 t需要满足如下条件: 1.它是s的子序列。 2.它的长度在1到4个字母之间。 换句话说,t包含至少一个,至多四个, 且在t中顺序与其在s中顺序相同的字母。 注意:t中的字母在s中并不是一个紧挨着一个出现的。 当原本的单词长度不超过4时,你不能再缩短它。 给出n个不同单词。你的任务是找出它们的短变形。 要求使得这些单词的短变形两两不同。 # 输入格式 输入文件的第一行只包含一个整数n。 接下来有n行,每行包含一个由小写字母组成的单词。 每个单词的长度不超过10。 # 输出格式 如果解决方案存在, 在输出文件中输出n行,第i行是输入文件中第i行 给出的单词的短变形。如果有不止一个满足条件的 短变形,输出其中任意一个。 如果不存在解决方案,输出-1。

加入题单

算法标签: