A8934 | New Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 title original 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.
A substring $s[l...\ r]$ $(1<=l<=r<=|s|)$ of string $s=s_{1}s_{2}...\ s_{|s|}$ (where $|s|$ is the length of string $s$ ) is string $s_{l}s_{l+1}...\ s_{r}$ .
String $x=x_{1}x_{2}...\ x_{p}$ is lexicographically smaller than string $y=y_{1}y_{2}...\ y_{q}$ , if either $p<q$ and $x_{1}=y_{1},x_{2}=y_{2},...\ ,x_{p}=y_{p}$ , or there exists such number $r$ $(r<p,r<q)$ , that $x_{1}=y_{1},x_{2}=y_{2},...\ ,x_{r}=y_{r}$ and $x_{r+1}<y_{r+1}$ . The string characters are compared by their ASCII codes.
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.
A substring $s[l...\ r]$ $(1<=l<=r<=|s|)$ of string $s=s_{1}s_{2}...\ s_{|s|}$ (where $|s|$ is the length of string $s$ ) is string $s_{l}s_{l+1}...\ s_{r}$ .
String $x=x_{1}x_{2}...\ x_{p}$ is lexicographically smaller than string $y=y_{1}y_{2}...\ y_{q}$ , if either $p<q$ and $x_{1}=y_{1},x_{2}=y_{2},...\ ,x_{p}=y_{p}$ , or there exists such number $r$ $(r<p,r<q)$ , that $x_{1}=y_{1},x_{2}=y_{2},...\ ,x_{r}=y_{r}$ and $x_{r+1}<y_{r+1}$ . The string characters are compared by their ASCII codes.
输入格式
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.
输出格式
Print a string, consisting of lowercase English letters — the lexicographically minimum shortest original title.
输入输出样例
输入 #1
5 threehorses goodsubstrings secret primematrix beautifulyear
输出 #1
j
输入 #2
4 aa bdefghijklmn opqrstuvwxyz c
输出 #2
ab
In the first sample the first 9 letters of the English alphabet (a, b, c, d, e, f, g, h, i) occur in the problem titles, so the answer is letter j.
In the second sample the titles contain 26 English letters, so the shortest original title cannot have length 1. Title aa occurs as a substring in the first title.
In the second sample the titles contain 26 English letters, so the shortest original title cannot have length 1. Title aa occurs as a substring in the first title.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted