公式
C - Concat (X-th) 解説
by
C - Concat (X-th) 解説
by
kyopro_friends
実際に \(N^K\) 個の文字列を全て求め、それらをソートすることでこの問題を解くことができます。
\(N^K\) 個の文字列の列挙は DFS により行うのが容易です。
writer解(Python)
N,K,X=map(int,input().split())
S=[input() for _ in range(N)]
ans=[]
def dfs(crr, count):
# count 個の文字列を結合して crr になった状態
if count==K:
ans.append(crr)
return
for s in S:
dfs(crr+s, count+1)
dfs("", 0)
ans.sort()
print(ans[X-1])
投稿日時:
最終更新: