QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 32 MB Puntuación total: 80

#13715. Tavan

Estadísticas

小 Željko 一直在阁楼里读他祖母的旧信,并发现了一个长度为 $N$ 的单词。不幸的是,由于墨水泼洒,他无法辨认出写了什么。

他在一张纸上重写了这个单词,将 $M$ 个模糊不清的字母中的每一个都替换为字符 #。他把这张纸递给他的祖母,祖母为每个模糊不清的字母提供了 $K$ 个不同的候选字母。之后,Željko 在笔记本上写下了所有可能的单词,并决定仔细观察它们的性质,以确定原本的单词是什么。在看到笔记本上写下的单词后,他的祖母意识到他们要找的单词是按字典序排列的第 $X$ 个。

学校里教字母表的那天 Željko 感冒流鼻涕了,所以他请求你帮助他确定原本的单词。

输入格式

第一行包含整数 $N$、$M$、$K$ 和 $X$($1 \le N \le 500$,$1 \le M \le N$,$1 \le K \le 26$,$1 \le X \le 10^9$)。

第二行包含 Željko 在纸上写的长度为 $N$ 的单词,由英文小写字母和字符 # 组成。

接下来的 $M$ 行中,每行包含一个长度为 $K$ 的单词,其中第 $i$ 个单词由可以替换第 $i$ 个模糊字母的字母组成。

数字 $X$ 将始终小于或等于可以构建的单词总数。

输出格式

输出的第一行必须包含按字典序排列的第 $X$ 个单词。

子任务

在占总分 30% 的测试数据中,满足 $M = 1$ 且 $K = 3$。

在另外占总分 30% 的测试数据中,满足 $M = 1$。

样例

输入样例 1

9 2 3 7
po#olje#i
sol
znu

输出样例 1

posoljeni

输入样例 2

4 1 2 2
#rak
zm

输出样例 2

zrak

说明

第一个样例的说明:

按字典序排列,所有可能的单词为:“pololjeni”、“pololjeui”、“pololjezi”、“poooljeni”、“poooljeui”、“poooljezi”、“posoljeni”、“posoljeui”、“posoljezi”。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.