logo AlgoBeat OnlineJudge
登录 注册

#208991. [NordicOI 2023] ChatNOI

内存限制:1024 MiB 时间限制:4000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

翻译自 NordicOI 2023 A 题 ChatNOI。


你正在和你的机器人玩一个对话游戏,规则是这样的:

首先给定一个包含了 个字符串的仅含小写字符串组 和一个数字 。

定义一个字符串组的质量为其每个长度为 的连续段的在 中出现的次数的最小值。

有 次询问,每次给定 与 个字符串。

你需要构造 个字符串,使得在给出的 个字符串后依次加入构造的 个字符串形成的字符串组质量最大。

若有多解,只需输出任意一个。

输入格式

第一行一个整数 和 。

第二行一句包含 个单词的句子 。

第三行一个整数 ,表示一共有 次询问。

然后 行,每行一个数 和长度为 的 的子字符串。

输出格式

你需要对于每个询问,输出 之后的 个单词。

样例

样例输入 1

13 2
ullen dullen doff kikke lane koff koffe lane bikke bane ullen dullen doff
3
1 ullen dullen
2 ullen dullen
3 ullen dullen

样例输出 1

doff 
doff kikke 
doff kikke lane 

样例输入 2

8 1
buffalo buffalo buffalo buffalo buffalo buffalo buffalo buffalo
1
7 buffalo

样例输出 2

buffalo buffalo buffalo buffalo buffalo buffalo buffalo 

样例输入 3

16 1
have you not heard about the bird the bird bird bird the bird is the word
8
1 have
1 you
1 not
1 heard
1 about
1 the
1 bird
1 is

样例输出 3

you 
not 
heard 
about 
the 
bird 
bird 
the 

数据范围与提示

本题采用捆绑测试。

令 。

  • Subtask 1(5 points):,,,。
  • Subtask 2(7 points):,,,。
  • Subtask 3(17 points):,,,。
  • Subtask 4(18 points):,,,。
  • Subtask 5(24 points):,,,。
  • Subtask 6(16 points):,,,。
  • Subtask 7(13 points):无特殊限制。

对于所有测试数据,,,,。