codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1536B.md (2223B)


      1 Source: https://codeforces.com/problemset/problem/1536/B
      2 
      3 B. Prinzessin der Verurteilung
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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?
     24 
     25 You are given a string of $n$ 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.
     26 
     27 A string $a$ is lexicographically smaller than a string $b$ if and only if one of the following holds:
     28 
     29 * $a$ is a prefix of $b$, but $a \ne b$;
     30 * in the first position where $a$ and $b$ differ, the string $a$ has a letter that appears earlier in the alphabet than the corresponding letter in $b$.
     31 
     32 A string $a$ is a substring of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
     33 
     34 Find out what the MEX of the string is!
     35 
     36 Input
     37 
     38 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \leq t \leq 1000$). Description of the test cases follows.
     39 
     40 The first line of each test case contains an integer $n$ ($1 \leq n \leq 1000$) — the length of the word. The second line for each test case contains a single string of $n$ lowercase Latin letters.
     41 
     42 The sum of $n$ over all test cases will not exceed $1000$.
     43 
     44 Output
     45 
     46 For each test case, output the MEX of the string on a new line.
     47 
     48 Example
     49 
     50 Input
     51 
     52 ```
     53 3
     54 28
     55 qaabzwsxedcrfvtgbyhnujmiklop
     56 13
     57 cleanairactbd
     58 10
     59 aannttoonn
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 ac
     66 f
     67 b
     68 ```