CF278B.New Problem

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

提出一道新题目并不像许多人想象的那样简单。有时,仅仅为题目起一个名字就已经非常困难了。我们称一个标题是“原创的”,当且仅当它不作为任何近期 Codeforces 题目标题的子串出现。

你已获得最近 nn 道题目的标题——这些标题均由小写英文字母组成的字符串。你的任务是找出最短的原创标题;若存在多个满足条件的标题,则选择其中字典序最小的一个。注意:题目的标题不能为空字符串。

字符串 s=s1s2…s∣s∣s = s_1 s_2 \dots s_{|s|}(其中 ∣s∣|s| 表示字符串 ss 的长度)的一个子串 s[l…r]s[l \dots r](1≤l≤r≤∣s∣1 \le l \le r \le |s|)定义为字符串 slsl+1…srs_l s_{l+1} \dots s_r。

字符串 x=x1x2…xpx = x_1 x_2 \dots x_p 在字典序上小于字符串 y=y1y2…yqy = y_1 y_2 \dots y_q,当且仅当以下任一条件成立:

  • p<qp < q,且 x1=y1, x2=y2, …, xp=ypx_1 = y_1,\, x_2 = y_2,\, \dots,\, x_p = y_p;
  • 或存在某个整数 rr(满足 r<pr < p 且 r<qr < q),使得 x1=y1, x2=y2, …, xr=yrx_1 = y_1,\, x_2 = y_2,\, \dots,\, x_r = y_r,且 xr+1<yr+1x_{r+1} < y_{r+1}。
    字符串中字符的比较依据其 ASCII 码值进行。

输入格式

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.

第一行包含一个整数 nn(1≤n≤301 \leq n \leq 30)—— 表示你需要考虑的标题数量。接下来是 nn 行,每行一个题目标题。每个标题仅由小写英文字母组成(特别地,不含任何空格),且长度在 11 到 2020(含)之间。

输出格式

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.

在第一个样例中,问题标题中出现了英文字母表的前 9 个字母(a、b、c、d、e、f、g、h、i),因此答案是字母 j。

在第二个样例中,标题包含了全部 26 个英文字母,因此最短的原始标题长度不可能为 1。子串 aa 出现在第一个标题中。

输入解题思路,AI测评打分。不知道怎么写?

首页