CF1924A.Did We Get Everything Covered?

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given two integers nn and kk along with a string ss.

Your task is to check whether all possible strings of length nn that can be formed using the first kk lowercase English alphabets occur as a subsequence of ss. If the answer is NO, you also need to print a string of length nn that can be formed using the first kk lowercase English alphabets which does not occur as a subsequence of ss.

If there are multiple answers, you may print any of them.

Note: A string aa is called a subsequence of another string bb if aa can be obtained by deleting some (possibly zero) characters from bb without changing the order of the remaining characters.

给你两个整数 nn 和 kk,以及一个字符串 ss。

你的任务是判断:所有由前 kk 个小写英文字母构成的长度为 nn 的字符串,是否都作为 ss 的子序列出现。如果答案为 NO,你还需要输出一个由前 kk 个小写英文字母构成的、长度为 nn 且不是 ss 的子序列的字符串。

如果有多个满足条件的答案,你可以输出其中任意一个。

注意:若字符串 aa 可通过从字符串 bb 中删除若干(可能为零)个字符、且不改变剩余字符的相对顺序而得到,则称 aa 是 bb 的子序列。

输入格式

The first line of input contains a single integer t (1≤t≤105)t \, (1 \le t \le 10^5), the number of test cases.

The first line of each test case contains 33 integers n (1≤n≤26), k (1≤k≤26), m (1≤m≤1000)n \, (1 \le n \le 26), \: k \, (1 \le k \le 26), \: m \, (1 \le m \le 1000), where nn and kk are the same as described in the input and mm is the length of the string ss.

The second line of each test case contains a single string ss of length mm, comprising only of the first kk lowercase English alphabets.

It is guaranteed that the sum of mm and the sum of nn over all test cases does not exceed 10610^6.

输入的第一行包含一个整数 t (1≤t≤105)t \, (1 \le t \le 10^5),表示测试用例的数量。

每个测试用例的第一行包含三个整数 n (1≤n≤26), k (1≤k≤26), m (1≤m≤1000)n \, (1 \le n \le 26), \: k \, (1 \le k \le 26), \: m \, (1 \le m \le 1000),其中 nn 和 kk 的含义与题面描述一致,mm 是字符串 ss 的长度。

每个测试用例的第二行包含一个长度为 mm 的字符串 ss,该字符串仅由前 kk 个小写英文字母组成。

保证所有测试用例中 mm 的总和以及 nn 的总和均不超过 10610^6。

输出格式

For each test case, print YES if all possible strings of length nn that can be formed using the first kk lowercase English alphabets occur as a subsequence of ss, else print NO.

If your answer is NO, print a string of length nn that can be formed using the first kk lowercase English alphabets which does not occur as a subsequence of ss 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).

对于每个测试用例,如果所有由前 kk 个小写英文字母构成的长度为 nn 的字符串均作为 ss 的子序列出现,则输出 YES;否则输出 NO。

若答案为 NO,请在下一行输出一个由前 kk 个小写英文字母构成、且不作为 ss 的子序列出现的长度为 nn 的字符串。

你可以以任意大小写形式输出 YES 或 NO 中的每个字母(例如,YES、yES、YeS 均被视为正确答案)。

输入输出样例

  • 输入#1

    3
    2 2 4
    abba
    2 2 3
    abb
    3 3 10
    aabbccabab

    输出#1

    YES
    NO
    aa
    NO
    ccc

说明/提示

For the first test case, all possible strings (aa, ab, ba, bb) of length 22 that can be formed using the first 22 English alphabets occur as a subsequence of abba.

For the second test case, the string aa is not a subsequence of abb.

对于第一个测试用例,所有由前 22 个英文字母构成的长度为 22 的可能字符串(即 aa、ab、ba、bb)均作为子序列出现在字符串 abba 中。

对于第二个测试用例,字符串 aa 不是字符串 abb 的子序列。

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

首页