CF1536B.Prinzessin der Verurteilung

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

I, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me.

It is no surprise Fischl speaks with a strange choice of words. However, this time, not even Oz, her raven friend, can interpret her expressions! Maybe you can help us understand what this young princess is saying?

You are given a string of nn lowercase Latin letters, the word that Fischl just spoke. You think that the MEX of this string may help you find the meaning behind this message. The MEX of the string is defined as the shortest string that doesn't appear as a contiguous substring in the input. If multiple strings exist, the lexicographically smallest one is considered the MEX. Note that the empty substring does NOT count as a valid MEX.

A string aa is lexicographically smaller than a string bb if and only if one of the following holds:

  • aa is a prefix of bb, but a≠ba \ne b;
  • in the first position where aa and bb differ, the string aa has a letter that appears earlier in the alphabet than the corresponding letter in bb.

A string aa is a substring of a string bb if aa can be obtained from bb by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

Find out what the MEX of the string is!

我,菲谢尔,断罪之皇女,奉命运之召降临此地——哦,你也是来自异世界的旅人?很好,我准许你与我同行。

菲谢尔说话时用词古怪,这并不令人意外。然而这一次,就连她的好友——渡鸦奥兹,也无法理解她的言辞!或许你能帮我们参透这位年轻公主话语背后的深意?

现给你一个由 nn 个小写拉丁字母组成的字符串,即菲谢尔刚刚说出的词语。你认为该字符串的 MEX(最小未出现子串)或许能助你揭开这条讯息的含义。字符串的 MEX 定义为:未在输入字符串中作为连续子串出现的最短字符串;若存在多个满足条件的字符串,则取其中字典序最小者作为 MEX。注意:空字符串不被视为合法的 MEX。

字符串 aa 的字典序严格小于字符串 bb,当且仅当满足以下任一条件:

  • aa 是 bb 的真前缀(即 aa 是 bb 的前缀,但 a≠ba \ne b);
  • 在 aa 与 bb 首次出现差异的位置上,aa 中对应位置的字母在字母表中位于 bb 中对应字母之前。

若字符串 aa 可通过对字符串 bb 删除其开头若干个(可能为零个或全部)字符及结尾若干个(可能为零个或全部)字符而得到,则称 aa 是 bb 的子串。

请找出该字符串的 MEX!

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \leq t \leq 1000). Description of the test cases follows.

The first line of each test case contains an integer nn (1≤n≤10001 \leq n \leq 1000) — the length of the word. The second line for each test case contains a single string of nn lowercase Latin letters.

The sum of nn over all test cases will not exceed 10001000.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤10001 \leq t \leq 1000)。随后是测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤10001 \leq n \leq 1000)—— 单词的长度。每个测试用例的第二行包含一个由 nn 个小写拉丁字母组成的字符串。

所有测试用例的 nn 值之和不超过 10001000。

输出格式

For each test case, output the MEX of the string on a new line.

对于每个测试用例,在一行中输出该字符串的 MEX。

输入输出样例

  • 输入#1

    3
    28
    qaabzwsxedcrfvtgbyhnujmiklop
    13
    cleanairactbd
    10
    aannttoonn

    输出#1

    ac
    f
    b

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

首页