AtCoder Beginner Contest 416
翻译中…
Problem Statement
翻译中…
You are given $N$ strings $S_1,\ldots,S_N$.
翻译中…
For a sequence $(A_1,\ldots,A_K)$ of length $K$ where all elements are between $1$ and $N$, inclusive, define the string $f(A_1,\ldots,A_K)$ as $S_{A_1}+S_{A_2}+\dots+S_{A_K}$. Here, + represents string concatenation.
翻译中…
Among all $f(A_1,\dots,A_K)$ for the $N^K$ sequences, find the lexicographically smallest string.
翻译中…
Constraints
翻译中…
$1\leq N \leq 10^5$$1\leq K \leq 10^5$$S_i$is a string consisting of lowercase English letters with length at most$10$.$N$and$K$are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N K
S_1
\vdots
S_N
翻译中…
Output
翻译中…
Output the answer.
翻译中…
样例
Input #1
3 2
abc
xxx
abc
Output #1
abcabc
- $f(1,1)=$ `abcabc`
- $f(1,2)=$ `abcxxx`
- $f(1,3)=$ `abcabc`
- $f(2,1)=$ `xxxabc`
- $f(2,2)=$ `xxxxxx`
- $f(2,3)=$ `xxxabc`
- $f(3,1)=$ `abcabc`
- $f(3,2)=$ `abcxxx`
- $f(3,3)=$ `abcabc`
Among these, the lexicographically smallest is `abcabc`.
Input #2
4 3
abcd
abc
ab
a
Output #2
aaa
Input #3
3 2
cba
cb
c
Output #3
cbac
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。