New Problem 解题报告

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
5
threehorses
goodsubstrings
secret
primematrix
beautifulyear
output
j
input
4
aa
bdefghijklmn
opqrstuvwxyz
c
output
ab
Note
 题目来源:  

codeforces 278B  

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值