CF1925A.We Got Everything Covered!

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given two positive integers nn and kk.

Your task is to find a string ss such that all possible strings of length nn that can be formed using the first kk lowercase English alphabets occur as a subsequence of ss.

If there are multiple answers, print the one with the smallest length. If there are still 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 的子序列出现。

如果存在多个满足条件的答案,请输出长度最短的那个;若仍存在多个长度最短的答案,你可以输出其中任意一个。

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

输入格式

The first line of input contains a single integer tt (1≤t≤6761\leq t\leq 676) denoting the number of test cases.

Each test case consists of a single line of input containing two integers nn (1≤n≤261\leq n\leq 26) and kk (1≤k≤261\leq k\leq 26).

输入的第一行包含一个整数 tt(1≤t≤6761\leq t\leq 676),表示测试用例的数量。

每个测试用例由一行输入组成,包含两个整数 nn(1≤n≤261\leq n\leq 26)和 kk(1≤k≤261\leq k\leq 26)。

输出格式

For each test case, print a single line containing a single string ss which satisfies the above property. If there are multiple answers, print the one with the smallest length. If there are still multiple answers, you may print any of them.

对于每个测试用例,输出一行,包含一个满足上述性质的字符串 ss。如果存在多个答案,输出长度最小的那个;如果仍存在多个答案,你可以输出其中任意一个。

输入输出样例

  • 输入#1

    4
    1 2
    2 1
    2 2
    2 3

    输出#1

    ab
    aa
    baab
    abcbac

说明/提示

For the first test case, there are two strings of length 11 which can be formed using the first 22 lowercase English alphabets, and they are present in ss as a subsequence as follows:

  • a:ab\texttt{a}: {\color{red}{\texttt{a}}}\texttt{b}
  • b:ab\texttt{b}: \texttt{a}{\color{red}{\texttt{b}}}

For the second test case, there is only one string of length 22 which can be formed using the first lowercase English alphabet, and it is present in ss as a subsequence as follows:

  • aa:aa\texttt{aa}: {\color{red}{\texttt{aa}}}

For the third test case, there are 44 strings of length 22 which can be formed using the first 22 lowercase English alphabets, and they are present in ss as a subsequence as follows:

  • aa:baab\texttt{aa}: \texttt{b}{\color{red}{\texttt{aa}}}\texttt{b}
  • ab:baab\texttt{ab}: \texttt{ba}{\color{red}{\texttt{ab}}}
  • ba:baab\texttt{ba}: {\color{red}{\texttt{ba}}}\texttt{ab}
  • bb:baab\texttt{bb}: {\color{red}{\texttt{b}}}\texttt{aa}{\color{red}{\texttt{b}}}

For the fourth test case, there are 99 strings of length 22 which can be formed using the first 33 lowercase English alphabets, and they are present in ss as a subsequence as follows:

  • aa:abcbac\texttt{aa}: {\color{red}{\texttt{a}}}\texttt{bcb}{\color{red}{\texttt{a}}}\texttt{c}
  • ab:abcbac\texttt{ab}: {\color{red}{\texttt{ab}}}\texttt{cbac}
  • ac:abcbac\texttt{ac}: \texttt{abcb}{\color{red}{\texttt{ac}}}
  • ba:abcbac\texttt{ba}: \texttt{abc}{\color{red}{\texttt{ba}}}\texttt{c}
  • bb:abcbac\texttt{bb}: \texttt{a}{\color{red}{\texttt{b}}}\texttt{c}{\color{red}{\texttt{b}}}\texttt{ac}
  • bc:abcbac\texttt{bc}: \texttt{a}{\color{red}{\texttt{bc}}}\texttt{bac}
  • ca:abcbac\texttt{ca}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{b}{\color{red}{\texttt{a}}}\texttt{c}
  • cb:abcbac\texttt{cb}: \texttt{ab}{\color{red}{\texttt{cb}}}\texttt{ac}
  • cc:abcbac\texttt{cc}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{ba}{\color{red}{\texttt{c}}}

对于第一个测试用例,使用前 22 个小写英文字母可以构造出两个长度为 11 的字符串,且它们均作为子序列出现在 ss 中,具体如下:

  • a:ab\texttt{a}: {\color{red}{\texttt{a}}}\texttt{b}
  • b:ab\texttt{b}: \texttt{a}{\color{red}{\texttt{b}}}

对于第二个测试用例,仅存在一个长度为 22 的字符串,它由第一个小写英文字母构成,且该字符串作为子序列出现在 ss 中,具体如下:

  • aa:aa\texttt{aa}: {\color{red}{\texttt{aa}}}

对于第三个测试用例,使用前 22 个小写英文字母可以构造出 44 个长度为 22 的字符串,且它们均作为子序列出现在 ss 中,具体如下:

  • aa:baab\texttt{aa}: \texttt{b}{\color{red}{\texttt{aa}}}\texttt{b}
  • ab:baab\texttt{ab}: \texttt{ba}{\color{red}{\texttt{ab}}}
  • ba:baab\texttt{ba}: {\color{red}{\texttt{ba}}}\texttt{ab}
  • bb:baab\texttt{bb}: {\color{red}{\texttt{b}}}\texttt{aa}{\color{red}{\texttt{b}}}

对于第四个测试用例,使用前 33 个小写英文字母可以构造出 99 个长度为 22 的字符串,且它们均作为子序列出现在 ss 中,具体如下:

  • aa:abcbac\texttt{aa}: {\color{red}{\texttt{a}}}\texttt{bcb}{\color{red}{\texttt{a}}}\texttt{c}
  • ab:abcbac\texttt{ab}: {\color{red}{\texttt{ab}}}\texttt{cbac}
  • ac:abcbac\texttt{ac}: \texttt{abcb}{\color{red}{\texttt{ac}}}
  • ba:abcbac\texttt{ba}: \texttt{abc}{\color{red}{\texttt{ba}}}\texttt{c}
  • bb:abcbac\texttt{bb}: \texttt{a}{\color{red}{\texttt{b}}}\texttt{c}{\color{red}{\texttt{b}}}\texttt{ac}
  • bc:abcbac\texttt{bc}: \texttt{a}{\color{red}{\texttt{bc}}}\texttt{bac}
  • ca:abcbac\texttt{ca}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{b}{\color{red}{\texttt{a}}}\texttt{c}
  • cb:abcbac\texttt{cb}: \texttt{ab}{\color{red}{\texttt{cb}}}\texttt{ac}
  • cc:abcbac\texttt{cc}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{ba}{\color{red}{\texttt{c}}}

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

首页