New Problem 解题报告

来源:互联网 发布:sql点击安装没反应 编辑:程序博客网 时间:2024/04/30 02:49
B. New Problem
time limit per test
 2 seconds
memory limit per test
 256 megabytes
input
 standard input
output
 standard output

Coming up with a new problem isn't as easy as many people think. Sometimes it is hard enough to name it. We'll consider a titleoriginal if it doesn't occur as a substring in any titles of recent Codeforces problems.

You've got the titles of n last problems — the strings, consisting of lowercase English letters. Your task is to find the shortest original title for the new problem. If there are multiple such titles, choose the lexicographically minimum one. Note, that title of the problem can't be an empty string.

substring s[l... r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2... s|s| (where |s| is the length of string s) is string slsl + 1... sr.

String x = x1x2... xp is lexicographically smaller than string y = y1y2... yq, if either p < q and x1 = y1, x2 = y2, ... , xp = yp, or there exists such number r (r < p, r < q), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 < yr + 1. The string characters are compared by their ASCII codes.

Input

The first line contains integer n (1 ≤ n ≤ 30) — the number of titles you've got to consider. Then follow n problem titles, one per line. Each title only consists of lowercase English letters (specifically, it doesn't contain any spaces) and has the length from 1 to 20, inclusive.

Output

Print a string, consisting of lowercase English letters — the lexicographically minimum shortest original title.

Sample test(s)
input
5threehorsesgoodsubstringssecretprimematrixbeautifulyear
output
j
input
4aabdefghijklmnopqrstuvwxyzc
output
ab
Note
 题目来源: 

codeforces 278B  

首先讲一下题意吧:就是在给出的所有串中,写出字典序最小的且在所有串中都没出现过的一条!
例如:ab<bb  bd<aaa
刚看这个题的时候感觉好难,但是看看数据也就是做多30个串,每个串最多20个char,那么暴力一下就可以了,把所有的组合放到map里面,然后再枚举所有的组合情况,也就是说BFS,每次产生一个结果就和map里面的对比,如果没有的话就……

上面的思路是我能想到的比较好的办法,但是目前看来还有更好的办法,就是这些个组合数目有限,也说,单个字母的有26种,两个字母组合的有26*26种,那么所有的给出的串中应该不可能涵盖所有的三个字母组合的情况……   而且还可以有库函数调用(strchr和strstr来查找吧),就算没有库函数调用,做到这一步了,那么接下来的就省事了……

http://blog.csdn.net/yangshuolll/article/details/8671222     参考链接地址!