A11353 | We Got Everything Covered!
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two positive integers $n$ and $k$ .
Your task is to find a string $s$ such that all possible strings of length $n$ that can be formed using the first $k$ lowercase English alphabets occur as a subsequence of $s$ .
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 $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.
Your task is to find a string $s$ such that all possible strings of length $n$ that can be formed using the first $k$ lowercase English alphabets occur as a subsequence of $s$ .
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 $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.
输入格式
The first line of input contains a single integer $t$ ( $1\leq t\leq 676$ ) denoting the number of test cases.
Each test case consists of a single line of input containing two integers $n$ ( $1\leq n\leq 26$ ) and $k$ ( $1\leq k\leq 26$ ).
Each test case consists of a single line of input containing two integers $n$ ( $1\leq n\leq 26$ ) and $k$ ( $1\leq k\leq 26$ ).
输出格式
For each test case, print a single line containing a single string $s$ 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.
输入输出样例
输入 #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 $1$ which can be formed using the first $2$ lowercase English alphabets, and they are present in $s$ as a subsequence as follows:
- $\texttt{a}: {\color{red}{\texttt{a}}}\texttt{b}$
- $\texttt{b}: \texttt{a}{\color{red}{\texttt{b}}}$
For the second test case, there is only one string of length $2$ which can be formed using the first lowercase English alphabet, and it is present in $s$ as a subsequence as follows:
- $\texttt{aa}: {\color{red}{\texttt{aa}}}$
For the third test case, there are $4$ strings of length $2$ which can be formed using the first $2$ lowercase English alphabets, and they are present in $s$ as a subsequence as follows:
- $\texttt{aa}: \texttt{b}{\color{red}{\texttt{aa}}}\texttt{b}$
- $\texttt{ab}: \texttt{ba}{\color{red}{\texttt{ab}}}$
- $\texttt{ba}: {\color{red}{\texttt{ba}}}\texttt{ab}$
- $\texttt{bb}: {\color{red}{\texttt{b}}}\texttt{aa}{\color{red}{\texttt{b}}}$
For the fourth test case, there are $9$ strings of length $2$ which can be formed using the first $3$ lowercase English alphabets, and they are present in $s$ as a subsequence as follows:
- $\texttt{aa}: {\color{red}{\texttt{a}}}\texttt{bcb}{\color{red}{\texttt{a}}}\texttt{c}$
- $\texttt{ab}: {\color{red}{\texttt{ab}}}\texttt{cbac}$
- $\texttt{ac}: \texttt{abcb}{\color{red}{\texttt{ac}}}$
- $\texttt{ba}: \texttt{abc}{\color{red}{\texttt{ba}}}\texttt{c}$
- $\texttt{bb}: \texttt{a}{\color{red}{\texttt{b}}}\texttt{c}{\color{red}{\texttt{b}}}\texttt{ac}$
- $\texttt{bc}: \texttt{a}{\color{red}{\texttt{bc}}}\texttt{bac}$
- $\texttt{ca}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{b}{\color{red}{\texttt{a}}}\texttt{c}$
- $\texttt{cb}: \texttt{ab}{\color{red}{\texttt{cb}}}\texttt{ac}$
- $\texttt{cc}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{ba}{\color{red}{\texttt{c}}}$
- $\texttt{a}: {\color{red}{\texttt{a}}}\texttt{b}$
- $\texttt{b}: \texttt{a}{\color{red}{\texttt{b}}}$
For the second test case, there is only one string of length $2$ which can be formed using the first lowercase English alphabet, and it is present in $s$ as a subsequence as follows:
- $\texttt{aa}: {\color{red}{\texttt{aa}}}$
For the third test case, there are $4$ strings of length $2$ which can be formed using the first $2$ lowercase English alphabets, and they are present in $s$ as a subsequence as follows:
- $\texttt{aa}: \texttt{b}{\color{red}{\texttt{aa}}}\texttt{b}$
- $\texttt{ab}: \texttt{ba}{\color{red}{\texttt{ab}}}$
- $\texttt{ba}: {\color{red}{\texttt{ba}}}\texttt{ab}$
- $\texttt{bb}: {\color{red}{\texttt{b}}}\texttt{aa}{\color{red}{\texttt{b}}}$
For the fourth test case, there are $9$ strings of length $2$ which can be formed using the first $3$ lowercase English alphabets, and they are present in $s$ as a subsequence as follows:
- $\texttt{aa}: {\color{red}{\texttt{a}}}\texttt{bcb}{\color{red}{\texttt{a}}}\texttt{c}$
- $\texttt{ab}: {\color{red}{\texttt{ab}}}\texttt{cbac}$
- $\texttt{ac}: \texttt{abcb}{\color{red}{\texttt{ac}}}$
- $\texttt{ba}: \texttt{abc}{\color{red}{\texttt{ba}}}\texttt{c}$
- $\texttt{bb}: \texttt{a}{\color{red}{\texttt{b}}}\texttt{c}{\color{red}{\texttt{b}}}\texttt{ac}$
- $\texttt{bc}: \texttt{a}{\color{red}{\texttt{bc}}}\texttt{bac}$
- $\texttt{ca}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{b}{\color{red}{\texttt{a}}}\texttt{c}$
- $\texttt{cb}: \texttt{ab}{\color{red}{\texttt{cb}}}\texttt{ac}$
- $\texttt{cc}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{ba}{\color{red}{\texttt{c}}}$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted