bzoj#P3012. [Usaco2012 Dec]First!
[Usaco2012 Dec]First!
题目描述
Bessie has been playing with strings again. She found that by changing the order of the alphabet she could make some strings come before all the others lexicographically (dictionary ordering). For instance Bessie found that for the strings , , , and she could make appear first using the standard alphabet and that she could make appear first using the alphabet . However, Bessie couldn't figure out any way to make or appear first.
Help Bessie by computing which strings in the input could be lexicographically first by rearranging the order of the alphabet. To compute if string is lexicographically before string find the index of the first character in which they differ, . If no such index exists then is lexicographically before if is shorter than . Otherwise is lexicographically before if occurs earlier in the alphabet than .
题目大意:给定 个总长不超过 的互不相同的字符串,现在你可以任意指定字符之间的大小关系。问有多少个串可能成为字典序最小的串,并输出这些串。
输入格式
Line 1: A single line containing , the number of strings Bessie is playing with.
Lines 2..1+n: Each line contains a non-empty string. The total number of characters in all strings will be no more than . All characters in input will be lowercase characters through . Input will contain no duplicate strings.
输出格式
Line 1: A single line containing , the number of strings that could be lexicographically first.
Lines 2..1+k: The 1+i th line should contain the th string that could be lexicographically first. Strings should be output in the same order they were given in the input.
样例输入
4
omm
moo
mom
ommnom
样例输出
2
omm
mom
提示
INPUT DETAILS: The example from the problem statement.
OUTPUT DETAILS: Only and can be ordered first.
数据规模与约定
对于100%的数据,, 。