CF727E.Games on a CD
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to k. The names didn't overlap.
Thus, there is a cyclic string of length n·k written on the CD.
Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were g popular games that days. All of the games he burned were among these g games, and no game was burned more than once.
You have to restore any valid list of games Tolya could burn to the CD several years ago.
几年前,托利亚有 n 款电脑游戏,某时他决定将这些游戏刻录到一张 CD 上。之后,他按顺时针方向,将游戏名称一个接一个地、首尾相接地写在 CD 上,构成一个环形序列。所有游戏名称互不相同,每个名称长度均为 k,且名称之间不重叠。
因此,CD 上写有一个长度为 n⋅k 的循环字符串。
几年过去了,如今托利亚已记不清自己当年刻录了哪些游戏。他只记得当时共有 g 款热门游戏,而他刻录的所有游戏均来自这 g 款热门游戏,且每款游戏至多刻录一次。
你需要还原出任意一个合法的游戏列表,即托利亚若干年前可能刻录到 CD 上的游戏序列。
输入格式
The first line of the input contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105) — the amount of games Tolya burned to the CD, and the length of each of the names.
The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is n·k. It is guaranteed that the length is not greater than 106.
The third line of the input contains one positive integer g (n ≤ g ≤ 105) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than 2·106.
Each of the next g lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length k. It is guaranteed that the names are distinct.
输入的第一行包含两个正整数 n 和 k(1 ≤ n ≤ 105,1 ≤ k ≤ 105)——分别表示托利亚刻录到光盘上的游戏数量,以及每个游戏名称的长度。
输入的第二行包含一个由小写英文字母组成的字符串——该字符串是托利亚写在光盘上的字符串,但被任意位置截断。该字符串的长度为 n⋅k。保证该长度不超过 106。
输入的第三行包含一个正整数 g(n ≤ g ≤ 105)——表示可能被写在光盘上的热门游戏的数量。保证所有热门游戏名称的总长度不超过 2⋅106。
接下来的 g 行中,每行包含一个字符串——某个热门游戏的名称。每个名称均由小写英文字母组成,且长度均为 k。保证所有名称互不相同。
输出格式
If there is no answer, print "NO" (without quotes).
Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print n integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them.
如果没有答案,输出 "NO"(不带引号)。
否则,输出两行。第一行输出 "YES"(不带引号)。第二行输出 n 个整数——即刻录在光盘上的游戏名称所对应的编号。你需要按照这些游戏可能被刻录到光盘上的顺序输出,即按顺时针顺序输出。你可以从任意位置开始输出。注意,每个游戏最多只被刻录一次。如果存在多种可能的答案,输出任意一种即可。
输入输出样例
输入#1
3 1 abc 4 b a c d
输出#1
YES 2 1 3
输入#2
4 2 aabbccdd 4 dd ab bc cd
输出#2
NO
输入解题思路,AI测评打分。不知道怎么写?