311031: CF1924A. Did We Get Everything Covered?
Description
You are given two integers $n$ and $k$ along with a string $s$.
Your task is to check whether all possible strings of length $n$ that can be formed using the first $k$ lowercase English alphabets occur as a subsequence of $s$. If the answer is NO, you also need to print a string of length $n$ that can be formed using the first $k$ lowercase English alphabets which does not occur as a subsequence of $s$.
If there are multiple answers, you may print any of them.
Note: A string $a$ is called a subsequence of another string $b$ if $a$ can be obtained by deleting some (possibly zero) characters from $b$ without changing the order of the remaining characters.
InputThe first line of input contains a single integer $t \, (1 \le t \le 10^5)$, the number of test cases.
The first line of each test case contains $3$ integers $n \, (1 \le n \le 26), \: k \, (1 \le k \le 26), \: m \, (1 \le m \le 1000)$, where $n$ and $k$ are the same as described in the input and $m$ is the length of the string $s$.
The second line of each test case contains a single string $s$ of length $m$, comprising only of the first $k$ lowercase English alphabets.
It is guaranteed that the sum of $m$ and the sum of $n$ over all test cases does not exceed $10^6$.
OutputFor each test case, print YES if all possible strings of length $n$ that can be formed using the first $k$ lowercase English alphabets occur as a subsequence of $s$, else print NO.
If your answer is NO, print a string of length $n$ that can be formed using the first $k$ lowercase English alphabets which does not occur as a subsequence of $s$ in the next line.
You may print each letter of YES or NO in any case (for example, YES, yES, YeS will all be recognized as a positive answer).
ExampleInput3 2 2 4 abba 2 2 3 abb 3 3 10 aabbccababOutput
YES NO aa NO cccNote
For the first test case, all possible strings (aa, ab, ba, bb) of length $2$ that can be formed using the first $2$ English alphabets occur as a subsequence of abba.
For the second test case, the string aa is not a subsequence of abb.
Output
给你两个整数n和k,以及一个字符串s。你的任务是检查所有长度为n的可能字符串(由前k个小写英文字母组成)是否都是s的子序列。如果答案是否定的,你还需要输出一个长度为n的字符串,该字符串由前k个小写英文字母组成,但它不是s的子序列。如果有多个答案,你可以输出其中任何一个。
输入数据格式:
第一行输入一个整数t(1≤t≤10^5),表示测试用例的数量。
每个测试用例的第一行包含3个整数n(1≤n≤26)、k(1≤k≤26)和m(1≤m≤1000),其中n和k如输入所述,m是字符串s的长度。
每个测试用例的第二行包含一个长度为m的字符串s,只包含前k个小写英文字母。
保证所有测试用例的m和n之和不超过10^6。
输出数据格式:
对于每个测试用例,如果所有长度为n的可能字符串(由前k个小写英文字母组成)都是s的子序列,则输出YES,否则输出NO。
如果你的答案是NO,请在下一行输出一个长度为n的字符串,该字符串由前k个小写英文字母组成,但它不是s的子序列。
YES或NO的每个字母你可以用任何大小写输出(例如,YES、yES、YeS都将被识别为肯定答案)。题目大意: 给你两个整数n和k,以及一个字符串s。你的任务是检查所有长度为n的可能字符串(由前k个小写英文字母组成)是否都是s的子序列。如果答案是否定的,你还需要输出一个长度为n的字符串,该字符串由前k个小写英文字母组成,但它不是s的子序列。如果有多个答案,你可以输出其中任何一个。 输入数据格式: 第一行输入一个整数t(1≤t≤10^5),表示测试用例的数量。 每个测试用例的第一行包含3个整数n(1≤n≤26)、k(1≤k≤26)和m(1≤m≤1000),其中n和k如输入所述,m是字符串s的长度。 每个测试用例的第二行包含一个长度为m的字符串s,只包含前k个小写英文字母。 保证所有测试用例的m和n之和不超过10^6。 输出数据格式: 对于每个测试用例,如果所有长度为n的可能字符串(由前k个小写英文字母组成)都是s的子序列,则输出YES,否则输出NO。 如果你的答案是NO,请在下一行输出一个长度为n的字符串,该字符串由前k个小写英文字母组成,但它不是s的子序列。 YES或NO的每个字母你可以用任何大小写输出(例如,YES、yES、YeS都将被识别为肯定答案)。